crimlab 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. crimlab-0.0.1/LICENSE +71 -0
  2. crimlab-0.0.1/MANIFEST.in +6 -0
  3. crimlab-0.0.1/NOTICE +6 -0
  4. crimlab-0.0.1/PKG-INFO +378 -0
  5. crimlab-0.0.1/README.md +360 -0
  6. crimlab-0.0.1/crimlab/__init__.py +1036 -0
  7. crimlab-0.0.1/crimlab/_clab.pyi +46 -0
  8. crimlab-0.0.1/crimlab/_corr.py +230 -0
  9. crimlab-0.0.1/crimlab/_disp.py +276 -0
  10. crimlab-0.0.1/crimlab/_frns.py +403 -0
  11. crimlab-0.0.1/crimlab/_j.py +8457 -0
  12. crimlab-0.0.1/crimlab/_out.py +237 -0
  13. crimlab-0.0.1/crimlab/_pol.py +189 -0
  14. crimlab-0.0.1/crimlab/_proof.py +47 -0
  15. crimlab-0.0.1/crimlab/_thm.py +251 -0
  16. crimlab-0.0.1/crimlab/_util.py +403 -0
  17. crimlab-0.0.1/crimlab/_version.py +1 -0
  18. crimlab-0.0.1/crimlab/lean/Benchmark.lean +60 -0
  19. crimlab-0.0.1/crimlab/lean/Burglary.lean +65 -0
  20. crimlab-0.0.1/crimlab/lean/Calib.lean +185 -0
  21. crimlab-0.0.1/crimlab/lean/Censor.lean +124 -0
  22. crimlab-0.0.1/crimlab/lean/Clearance.lean +82 -0
  23. crimlab-0.0.1/crimlab/lean/Concentration.lean +43 -0
  24. crimlab-0.0.1/crimlab/lean/Contagion.lean +41 -0
  25. crimlab-0.0.1/crimlab/lean/Custody.lean +135 -0
  26. crimlab-0.0.1/crimlab/lean/Dark.lean +51 -0
  27. crimlab-0.0.1/crimlab/lean/Did.lean +48 -0
  28. crimlab-0.0.1/crimlab/lean/Dyad.lean +53 -0
  29. crimlab-0.0.1/crimlab/lean/Etas.lean +27 -0
  30. crimlab-0.0.1/crimlab/lean/Exposure.lean +122 -0
  31. crimlab-0.0.1/crimlab/lean/Fair.lean +191 -0
  32. crimlab-0.0.1/crimlab/lean/Flow.lean +39 -0
  33. crimlab-0.0.1/crimlab/lean/Forensics.lean +377 -0
  34. crimlab-0.0.1/crimlab/lean/Hazard.lean +58 -0
  35. crimlab-0.0.1/crimlab/lean/Hotspot.lean +153 -0
  36. crimlab-0.0.1/crimlab/lean/Ident.lean +509 -0
  37. crimlab-0.0.1/crimlab/lean/Incap.lean +269 -0
  38. crimlab-0.0.1/crimlab/lean/Judge.lean +48 -0
  39. crimlab-0.0.1/crimlab/lean/Learn.lean +147 -0
  40. crimlab-0.0.1/crimlab/lean/LifeCourse.lean +31 -0
  41. crimlab-0.0.1/crimlab/lean/Misclass.lean +119 -0
  42. crimlab-0.0.1/crimlab/lean/Network.lean +226 -0
  43. crimlab-0.0.1/crimlab/lean/Oaxaca.lean +88 -0
  44. crimlab-0.0.1/crimlab/lean/OutcomeTest.lean +67 -0
  45. crimlab-0.0.1/crimlab/lean/Patrol.lean +35 -0
  46. crimlab-0.0.1/crimlab/lean/Published.lean +37 -0
  47. crimlab-0.0.1/crimlab/lean/Rates.lean +66 -0
  48. crimlab-0.0.1/crimlab/lean/Recur.lean +33 -0
  49. crimlab-0.0.1/crimlab/lean/RegMean.lean +112 -0
  50. crimlab-0.0.1/crimlab/lean/RelChk.lean +78 -0
  51. crimlab-0.0.1/crimlab/lean/RelRisk.lean +77 -0
  52. crimlab-0.0.1/crimlab/lean/Select.lean +199 -0
  53. crimlab-0.0.1/crimlab/lean/Sentence.lean +107 -0
  54. crimlab-0.0.1/crimlab/lean/Series.lean +42 -0
  55. crimlab-0.0.1/crimlab/lean/Spatial.lean +291 -0
  56. crimlab-0.0.1/crimlab/lean/Table.lean +44 -0
  57. crimlab-0.0.1/crimlab/lean/Veil.lean +112 -0
  58. crimlab-0.0.1/crimlab/lean/Volat.lean +407 -0
  59. crimlab-0.0.1/crimlab/py.typed +0 -0
  60. crimlab-0.0.1/crimlab.egg-info/PKG-INFO +378 -0
  61. crimlab-0.0.1/crimlab.egg-info/SOURCES.txt +449 -0
  62. crimlab-0.0.1/crimlab.egg-info/dependency_links.txt +1 -0
  63. crimlab-0.0.1/crimlab.egg-info/top_level.txt +1 -0
  64. crimlab-0.0.1/ext/clab.cpp +2344 -0
  65. crimlab-0.0.1/ext/k/ahl.cpp +124 -0
  66. crimlab-0.0.1/ext/k/aor.cpp +127 -0
  67. crimlab-0.0.1/ext/k/apc.cpp +121 -0
  68. crimlab-0.0.1/ext/k/apol.cpp +297 -0
  69. crimlab-0.0.1/ext/k/apx.cpp +1325 -0
  70. crimlab-0.0.1/ext/k/arl.cpp +72 -0
  71. crimlab-0.0.1/ext/k/bfx.h +84 -0
  72. crimlab-0.0.1/ext/k/bnf.cpp +223 -0
  73. crimlab-0.0.1/ext/k/bpm.cpp +153 -0
  74. crimlab-0.0.1/ext/k/buf.cpp +38 -0
  75. crimlab-0.0.1/ext/k/cal.cpp +346 -0
  76. crimlab-0.0.1/ext/k/cba.cpp +334 -0
  77. crimlab-0.0.1/ext/k/cem.cpp +102 -0
  78. crimlab-0.0.1/ext/k/cgeo.cpp +306 -0
  79. crimlab-0.0.1/ext/k/cgeo.h +120 -0
  80. crimlab-0.0.1/ext/k/cgr.cpp +170 -0
  81. crimlab-0.0.1/ext/k/chm.cpp +191 -0
  82. crimlab-0.0.1/ext/k/cmps.cpp +249 -0
  83. crimlab-0.0.1/ext/k/cnc.cpp +381 -0
  84. crimlab-0.0.1/ext/k/cnt.cpp +746 -0
  85. crimlab-0.0.1/ext/k/codes.inc +184 -0
  86. crimlab-0.0.1/ext/k/core.cpp +662 -0
  87. crimlab-0.0.1/ext/k/crimlab.h +5084 -0
  88. crimlab-0.0.1/ext/k/dag.cpp +69 -0
  89. crimlab-0.0.1/ext/k/dens.cpp +563 -0
  90. crimlab-0.0.1/ext/k/dfit.cpp +670 -0
  91. crimlab-0.0.1/ext/k/dfmt.h +249 -0
  92. crimlab-0.0.1/ext/k/did.cpp +492 -0
  93. crimlab-0.0.1/ext/k/dkf.cpp +117 -0
  94. crimlab-0.0.1/ext/k/dml.cpp +983 -0
  95. crimlab-0.0.1/ext/k/dpn.cpp +874 -0
  96. crimlab-0.0.1/ext/k/dpnd.cpp +1361 -0
  97. crimlab-0.0.1/ext/k/dpnd.h +102 -0
  98. crimlab-0.0.1/ext/k/drf.cpp +201 -0
  99. crimlab-0.0.1/ext/k/dsc.cpp +889 -0
  100. crimlab-0.0.1/ext/k/dscd.cpp +495 -0
  101. crimlab-0.0.1/ext/k/dscd.h +70 -0
  102. crimlab-0.0.1/ext/k/dst.cpp +1039 -0
  103. crimlab-0.0.1/ext/k/dtr.cpp +218 -0
  104. crimlab-0.0.1/ext/k/dwn.cpp +288 -0
  105. crimlab-0.0.1/ext/k/env.cpp +344 -0
  106. crimlab-0.0.1/ext/k/eof.cpp +98 -0
  107. crimlab-0.0.1/ext/k/fair.cpp +545 -0
  108. crimlab-0.0.1/ext/k/fls.cpp +89 -0
  109. crimlab-0.0.1/ext/k/flw.cpp +488 -0
  110. crimlab-0.0.1/ext/k/fp.cpp +210 -0
  111. crimlab-0.0.1/ext/k/fpdat.cpp +635 -0
  112. crimlab-0.0.1/ext/k/fpdat.h +30 -0
  113. crimlab-0.0.1/ext/k/fpio.cpp +262 -0
  114. crimlab-0.0.1/ext/k/frx.h +88 -0
  115. crimlab-0.0.1/ext/k/fsim.cpp +94 -0
  116. crimlab-0.0.1/ext/k/geo.cpp +86 -0
  117. crimlab-0.0.1/ext/k/geo2.cpp +61 -0
  118. crimlab-0.0.1/ext/k/geou.cpp +120 -0
  119. crimlab-0.0.1/ext/k/gla.cpp +144 -0
  120. crimlab-0.0.1/ext/k/gla.h +261 -0
  121. crimlab-0.0.1/ext/k/gmx.cpp +586 -0
  122. crimlab-0.0.1/ext/k/gol.cpp +150 -0
  123. crimlab-0.0.1/ext/k/gst.cpp +146 -0
  124. crimlab-0.0.1/ext/k/gsw.cpp +126 -0
  125. crimlab-0.0.1/ext/k/gtw.cpp +166 -0
  126. crimlab-0.0.1/ext/k/hot.cpp +294 -0
  127. crimlab-0.0.1/ext/k/hsa.cpp +116 -0
  128. crimlab-0.0.1/ext/k/hsp.cpp +488 -0
  129. crimlab-0.0.1/ext/k/hwk.cpp +448 -0
  130. crimlab-0.0.1/ext/k/hyq.cpp +126 -0
  131. crimlab-0.0.1/ext/k/ibn.cpp +488 -0
  132. crimlab-0.0.1/ext/k/idw.cpp +102 -0
  133. crimlab-0.0.1/ext/k/ifx.cpp +314 -0
  134. crimlab-0.0.1/ext/k/igc.cpp +1037 -0
  135. crimlab-0.0.1/ext/k/igf.cpp +629 -0
  136. crimlab-0.0.1/ext/k/igh.cpp +610 -0
  137. crimlab-0.0.1/ext/k/igh.h +73 -0
  138. crimlab-0.0.1/ext/k/igk.h +180 -0
  139. crimlab-0.0.1/ext/k/igm.cpp +1076 -0
  140. crimlab-0.0.1/ext/k/igv.cpp +934 -0
  141. crimlab-0.0.1/ext/k/jaexp.inc +225 -0
  142. crimlab-0.0.1/ext/k/jaor.inc +164 -0
  143. crimlab-0.0.1/ext/k/japc.inc +81 -0
  144. crimlab-0.0.1/ext/k/japol.inc +1028 -0
  145. crimlab-0.0.1/ext/k/japx.inc +2849 -0
  146. crimlab-0.0.1/ext/k/jaud.inc +159 -0
  147. crimlab-0.0.1/ext/k/jax2.inc +1136 -0
  148. crimlab-0.0.1/ext/k/jcat.inc +460 -0
  149. crimlab-0.0.1/ext/k/jcba.inc +315 -0
  150. crimlab-0.0.1/ext/k/jchk.inc +461 -0
  151. crimlab-0.0.1/ext/k/jcnc.inc +388 -0
  152. crimlab-0.0.1/ext/k/jdfit.inc +278 -0
  153. crimlab-0.0.1/ext/k/jdg.cpp +260 -0
  154. crimlab-0.0.1/ext/k/jdid.inc +1253 -0
  155. crimlab-0.0.1/ext/k/jdrf.inc +161 -0
  156. crimlab-0.0.1/ext/k/jdsc.inc +975 -0
  157. crimlab-0.0.1/ext/k/jdtr.inc +312 -0
  158. crimlab-0.0.1/ext/k/jdwn.inc +256 -0
  159. crimlab-0.0.1/ext/k/jenv.inc +922 -0
  160. crimlab-0.0.1/ext/k/jfair.inc +581 -0
  161. crimlab-0.0.1/ext/k/jflw.inc +1001 -0
  162. crimlab-0.0.1/ext/k/jfp.inc +206 -0
  163. crimlab-0.0.1/ext/k/jfp2.inc +290 -0
  164. crimlab-0.0.1/ext/k/jfrx.inc +288 -0
  165. crimlab-0.0.1/ext/k/jgeo.inc +269 -0
  166. crimlab-0.0.1/ext/k/jgol.inc +223 -0
  167. crimlab-0.0.1/ext/k/jhot.inc +80 -0
  168. crimlab-0.0.1/ext/k/jhsa.inc +60 -0
  169. crimlab-0.0.1/ext/k/jhw.inc +218 -0
  170. crimlab-0.0.1/ext/k/jhwk.inc +150 -0
  171. crimlab-0.0.1/ext/k/jibn.inc +89 -0
  172. crimlab-0.0.1/ext/k/jigh.inc +171 -0
  173. crimlab-0.0.1/ext/k/jjdg.inc +321 -0
  174. crimlab-0.0.1/ext/k/jkrg.inc +413 -0
  175. crimlab-0.0.1/ext/k/jlearn.inc +613 -0
  176. crimlab-0.0.1/ext/k/jlnk.inc +122 -0
  177. crimlab-0.0.1/ext/k/jlnr.inc +147 -0
  178. crimlab-0.0.1/ext/k/jmap.inc +562 -0
  179. crimlab-0.0.1/ext/k/jmnd.inc +139 -0
  180. crimlab-0.0.1/ext/k/jmtr.inc +42 -0
  181. crimlab-0.0.1/ext/k/jnet.inc +456 -0
  182. crimlab-0.0.1/ext/k/jovr.inc +701 -0
  183. crimlab-0.0.1/ext/k/jpchk.inc +244 -0
  184. crimlab-0.0.1/ext/k/jplt.inc +549 -0
  185. crimlab-0.0.1/ext/k/jplt2.inc +416 -0
  186. crimlab-0.0.1/ext/k/jprep.inc +921 -0
  187. crimlab-0.0.1/ext/k/jprh.inc +50 -0
  188. crimlab-0.0.1/ext/k/jprim.inc +357 -0
  189. crimlab-0.0.1/ext/k/jpub.inc +173 -0
  190. crimlab-0.0.1/ext/k/jrat.inc +743 -0
  191. crimlab-0.0.1/ext/k/jrdd.inc +196 -0
  192. crimlab-0.0.1/ext/k/jrpv.inc +77 -0
  193. crimlab-0.0.1/ext/k/jrtm.inc +373 -0
  194. crimlab-0.0.1/ext/k/jrun.cpp +2408 -0
  195. crimlab-0.0.1/ext/k/jrun.h +45 -0
  196. crimlab-0.0.1/ext/k/jsar.inc +546 -0
  197. crimlab-0.0.1/ext/k/jsens.inc +48 -0
  198. crimlab-0.0.1/ext/k/jsep.inc +377 -0
  199. crimlab-0.0.1/ext/k/jshrs.inc +184 -0
  200. crimlab-0.0.1/ext/k/jskch.inc +216 -0
  201. crimlab-0.0.1/ext/k/json.h +340 -0
  202. crimlab-0.0.1/ext/k/jsp.inc +828 -0
  203. crimlab-0.0.1/ext/k/jsp2.inc +429 -0
  204. crimlab-0.0.1/ext/k/jspc.inc +99 -0
  205. crimlab-0.0.1/ext/k/jspi.inc +737 -0
  206. crimlab-0.0.1/ext/k/jspx.inc +1183 -0
  207. crimlab-0.0.1/ext/k/jsvt.inc +210 -0
  208. crimlab-0.0.1/ext/k/jsvy.inc +186 -0
  209. crimlab-0.0.1/ext/k/jtc.cpp +256 -0
  210. crimlab-0.0.1/ext/k/jthr.inc +325 -0
  211. crimlab-0.0.1/ext/k/jtm.inc +1025 -0
  212. crimlab-0.0.1/ext/k/jtox.inc +183 -0
  213. crimlab-0.0.1/ext/k/jtrace.inc +170 -0
  214. crimlab-0.0.1/ext/k/jtrj.inc +146 -0
  215. crimlab-0.0.1/ext/k/jtxt.inc +88 -0
  216. crimlab-0.0.1/ext/k/jvrf.inc +1163 -0
  217. crimlab-0.0.1/ext/k/jwcb.inc +354 -0
  218. crimlab-0.0.1/ext/k/jwdq.inc +16 -0
  219. crimlab-0.0.1/ext/k/jx.inc +715 -0
  220. crimlab-0.0.1/ext/k/jxpl.inc +327 -0
  221. crimlab-0.0.1/ext/k/jxpr.inc +1081 -0
  222. crimlab-0.0.1/ext/k/jxw.inc +340 -0
  223. crimlab-0.0.1/ext/k/jyoy.inc +631 -0
  224. crimlab-0.0.1/ext/k/jyoyh.inc +388 -0
  225. crimlab-0.0.1/ext/k/jyoyp.inc +242 -0
  226. crimlab-0.0.1/ext/k/kmr.cpp +123 -0
  227. crimlab-0.0.1/ext/k/knx.cpp +112 -0
  228. crimlab-0.0.1/ext/k/krg.cpp +577 -0
  229. crimlab-0.0.1/ext/k/kscn.cpp +225 -0
  230. crimlab-0.0.1/ext/k/kutil.cpp +60 -0
  231. crimlab-0.0.1/ext/k/kutil.h +202 -0
  232. crimlab-0.0.1/ext/k/lab.cpp +142 -0
  233. crimlab-0.0.1/ext/k/lcr.cpp +138 -0
  234. crimlab-0.0.1/ext/k/learn.cpp +695 -0
  235. crimlab-0.0.1/ext/k/learn.h +102 -0
  236. crimlab-0.0.1/ext/k/lnk.cpp +111 -0
  237. crimlab-0.0.1/ext/k/lnr.cpp +230 -0
  238. crimlab-0.0.1/ext/k/lsa.cpp +377 -0
  239. crimlab-0.0.1/ext/k/lws.cpp +170 -0
  240. crimlab-0.0.1/ext/k/map.cpp +168 -0
  241. crimlab-0.0.1/ext/k/mhk.cpp +452 -0
  242. crimlab-0.0.1/ext/k/mip.cpp +236 -0
  243. crimlab-0.0.1/ext/k/mnd.cpp +78 -0
  244. crimlab-0.0.1/ext/k/mtr.cpp +87 -0
  245. crimlab-0.0.1/ext/k/mvt.cpp +248 -0
  246. crimlab-0.0.1/ext/k/net.cpp +848 -0
  247. crimlab-0.0.1/ext/k/nnd.cpp +120 -0
  248. crimlab-0.0.1/ext/k/oax.cpp +206 -0
  249. crimlab-0.0.1/ext/k/ovr.cpp +1100 -0
  250. crimlab-0.0.1/ext/k/ped.cpp +607 -0
  251. crimlab-0.0.1/ext/k/pev.h +137 -0
  252. crimlab-0.0.1/ext/k/pevc.h +71 -0
  253. crimlab-0.0.1/ext/k/pevs.h +65 -0
  254. crimlab-0.0.1/ext/k/pevw.h +49 -0
  255. crimlab-0.0.1/ext/k/plf.cpp +68 -0
  256. crimlab-0.0.1/ext/k/plp.cpp +77 -0
  257. crimlab-0.0.1/ext/k/plr.cpp +327 -0
  258. crimlab-0.0.1/ext/k/ppx.cpp +241 -0
  259. crimlab-0.0.1/ext/k/pre.inc +465 -0
  260. crimlab-0.0.1/ext/k/prh.cpp +89 -0
  261. crimlab-0.0.1/ext/k/prim.cpp +384 -0
  262. crimlab-0.0.1/ext/k/psc.cpp +26 -0
  263. crimlab-0.0.1/ext/k/pub.cpp +161 -0
  264. crimlab-0.0.1/ext/k/pwa.cpp +78 -0
  265. crimlab-0.0.1/ext/k/pwr.cpp +927 -0
  266. crimlab-0.0.1/ext/k/pwr.h +114 -0
  267. crimlab-0.0.1/ext/k/pwrd.cpp +335 -0
  268. crimlab-0.0.1/ext/k/pwrmac.cpp +321 -0
  269. crimlab-0.0.1/ext/k/pwrwin.cpp +259 -0
  270. crimlab-0.0.1/ext/k/pws.cpp +120 -0
  271. crimlab-0.0.1/ext/k/qn.cpp +286 -0
  272. crimlab-0.0.1/ext/k/qn.h +56 -0
  273. crimlab-0.0.1/ext/k/rat.cpp +209 -0
  274. crimlab-0.0.1/ext/k/rct.cpp +193 -0
  275. crimlab-0.0.1/ext/k/rdd.cpp +371 -0
  276. crimlab-0.0.1/ext/k/rf.cpp +281 -0
  277. crimlab-0.0.1/ext/k/rnd.cpp +70 -0
  278. crimlab-0.0.1/ext/k/rpk.cpp +232 -0
  279. crimlab-0.0.1/ext/k/rpt.cpp +36 -0
  280. crimlab-0.0.1/ext/k/rpv.cpp +98 -0
  281. crimlab-0.0.1/ext/k/rsc.cpp +169 -0
  282. crimlab-0.0.1/ext/k/rtm.cpp +98 -0
  283. crimlab-0.0.1/ext/k/sar.cpp +637 -0
  284. crimlab-0.0.1/ext/k/sdb.cpp +176 -0
  285. crimlab-0.0.1/ext/k/selftest.cpp +583 -0
  286. crimlab-0.0.1/ext/k/sens.cpp +168 -0
  287. crimlab-0.0.1/ext/k/sep.cpp +834 -0
  288. crimlab-0.0.1/ext/k/sev.cpp +68 -0
  289. crimlab-0.0.1/ext/k/sfx.cpp +517 -0
  290. crimlab-0.0.1/ext/k/sk.cpp +108 -0
  291. crimlab-0.0.1/ext/k/skch.cpp +230 -0
  292. crimlab-0.0.1/ext/k/sp2.cpp +391 -0
  293. crimlab-0.0.1/ext/k/spc.cpp +131 -0
  294. crimlab-0.0.1/ext/k/spr.cpp +196 -0
  295. crimlab-0.0.1/ext/k/spt.cpp +145 -0
  296. crimlab-0.0.1/ext/k/sreg.cpp +984 -0
  297. crimlab-0.0.1/ext/k/srr.h +125 -0
  298. crimlab-0.0.1/ext/k/srrsp.h +94 -0
  299. crimlab-0.0.1/ext/k/stg.cpp +303 -0
  300. crimlab-0.0.1/ext/k/stm.cpp +137 -0
  301. crimlab-0.0.1/ext/k/svb.cpp +1784 -0
  302. crimlab-0.0.1/ext/k/svg.cpp +263 -0
  303. crimlab-0.0.1/ext/k/svk.h +165 -0
  304. crimlab-0.0.1/ext/k/svla.cpp +860 -0
  305. crimlab-0.0.1/ext/k/svt.cpp +2341 -0
  306. crimlab-0.0.1/ext/k/svy.cpp +46 -0
  307. crimlab-0.0.1/ext/k/swt.cpp +207 -0
  308. crimlab-0.0.1/ext/k/syn.cpp +202 -0
  309. crimlab-0.0.1/ext/k/t_aor.cpp +184 -0
  310. crimlab-0.0.1/ext/k/t_apc.cpp +53 -0
  311. crimlab-0.0.1/ext/k/t_apol.cpp +65 -0
  312. crimlab-0.0.1/ext/k/t_apx.cpp +425 -0
  313. crimlab-0.0.1/ext/k/t_bnf.cpp +249 -0
  314. crimlab-0.0.1/ext/k/t_buf.cpp +47 -0
  315. crimlab-0.0.1/ext/k/t_cal.cpp +153 -0
  316. crimlab-0.0.1/ext/k/t_cgr.cpp +723 -0
  317. crimlab-0.0.1/ext/k/t_chm.cpp +149 -0
  318. crimlab-0.0.1/ext/k/t_cmps.cpp +64 -0
  319. crimlab-0.0.1/ext/k/t_cnc.cpp +248 -0
  320. crimlab-0.0.1/ext/k/t_cnt.cpp +217 -0
  321. crimlab-0.0.1/ext/k/t_corr.cpp +334 -0
  322. crimlab-0.0.1/ext/k/t_dfit.cpp +52 -0
  323. crimlab-0.0.1/ext/k/t_did.cpp +181 -0
  324. crimlab-0.0.1/ext/k/t_disp.cpp +279 -0
  325. crimlab-0.0.1/ext/k/t_dkf.cpp +96 -0
  326. crimlab-0.0.1/ext/k/t_dml.cpp +684 -0
  327. crimlab-0.0.1/ext/k/t_dpn.cpp +217 -0
  328. crimlab-0.0.1/ext/k/t_drf.cpp +38 -0
  329. crimlab-0.0.1/ext/k/t_dsc.cpp +85 -0
  330. crimlab-0.0.1/ext/k/t_dst.cpp +198 -0
  331. crimlab-0.0.1/ext/k/t_dtr.cpp +141 -0
  332. crimlab-0.0.1/ext/k/t_dwn.cpp +126 -0
  333. crimlab-0.0.1/ext/k/t_env.cpp +177 -0
  334. crimlab-0.0.1/ext/k/t_fair.cpp +423 -0
  335. crimlab-0.0.1/ext/k/t_flw.cpp +260 -0
  336. crimlab-0.0.1/ext/k/t_fp.cpp +68 -0
  337. crimlab-0.0.1/ext/k/t_frns.cpp +342 -0
  338. crimlab-0.0.1/ext/k/t_fsim.cpp +86 -0
  339. crimlab-0.0.1/ext/k/t_geo.cpp +221 -0
  340. crimlab-0.0.1/ext/k/t_geo2.cpp +99 -0
  341. crimlab-0.0.1/ext/k/t_geou.cpp +78 -0
  342. crimlab-0.0.1/ext/k/t_gmx.cpp +75 -0
  343. crimlab-0.0.1/ext/k/t_gol.cpp +25 -0
  344. crimlab-0.0.1/ext/k/t_gst.cpp +251 -0
  345. crimlab-0.0.1/ext/k/t_hot.cpp +184 -0
  346. crimlab-0.0.1/ext/k/t_hsa.cpp +44 -0
  347. crimlab-0.0.1/ext/k/t_hsp.cpp +574 -0
  348. crimlab-0.0.1/ext/k/t_hwk.cpp +296 -0
  349. crimlab-0.0.1/ext/k/t_hyq.cpp +76 -0
  350. crimlab-0.0.1/ext/k/t_ibn.cpp +62 -0
  351. crimlab-0.0.1/ext/k/t_igh.cpp +153 -0
  352. crimlab-0.0.1/ext/k/t_jdg.cpp +168 -0
  353. crimlab-0.0.1/ext/k/t_jtc.cpp +470 -0
  354. crimlab-0.0.1/ext/k/t_kmr.cpp +63 -0
  355. crimlab-0.0.1/ext/k/t_knx.cpp +126 -0
  356. crimlab-0.0.1/ext/k/t_krg.cpp +208 -0
  357. crimlab-0.0.1/ext/k/t_kscn.cpp +123 -0
  358. crimlab-0.0.1/ext/k/t_lab.cpp +287 -0
  359. crimlab-0.0.1/ext/k/t_lcr.cpp +101 -0
  360. crimlab-0.0.1/ext/k/t_learn.cpp +431 -0
  361. crimlab-0.0.1/ext/k/t_lnk.cpp +36 -0
  362. crimlab-0.0.1/ext/k/t_lnr.cpp +102 -0
  363. crimlab-0.0.1/ext/k/t_lws.cpp +98 -0
  364. crimlab-0.0.1/ext/k/t_map.cpp +151 -0
  365. crimlab-0.0.1/ext/k/t_mhk.cpp +186 -0
  366. crimlab-0.0.1/ext/k/t_mnd.cpp +73 -0
  367. crimlab-0.0.1/ext/k/t_mtr.cpp +33 -0
  368. crimlab-0.0.1/ext/k/t_mvt.cpp +259 -0
  369. crimlab-0.0.1/ext/k/t_net.cpp +902 -0
  370. crimlab-0.0.1/ext/k/t_nnd.cpp +305 -0
  371. crimlab-0.0.1/ext/k/t_oax.cpp +79 -0
  372. crimlab-0.0.1/ext/k/t_orc.cpp +161 -0
  373. crimlab-0.0.1/ext/k/t_ovr.cpp +163 -0
  374. crimlab-0.0.1/ext/k/t_ped.cpp +130 -0
  375. crimlab-0.0.1/ext/k/t_plr.cpp +39 -0
  376. crimlab-0.0.1/ext/k/t_pol.cpp +359 -0
  377. crimlab-0.0.1/ext/k/t_ppx.cpp +129 -0
  378. crimlab-0.0.1/ext/k/t_prh.cpp +29 -0
  379. crimlab-0.0.1/ext/k/t_prim.cpp +81 -0
  380. crimlab-0.0.1/ext/k/t_pub.cpp +143 -0
  381. crimlab-0.0.1/ext/k/t_pwr.cpp +200 -0
  382. crimlab-0.0.1/ext/k/t_rat.cpp +110 -0
  383. crimlab-0.0.1/ext/k/t_rf.cpp +164 -0
  384. crimlab-0.0.1/ext/k/t_rpk.cpp +383 -0
  385. crimlab-0.0.1/ext/k/t_rpt.cpp +143 -0
  386. crimlab-0.0.1/ext/k/t_rpv.cpp +54 -0
  387. crimlab-0.0.1/ext/k/t_rtm.cpp +113 -0
  388. crimlab-0.0.1/ext/k/t_sar.cpp +88 -0
  389. crimlab-0.0.1/ext/k/t_sdb.cpp +154 -0
  390. crimlab-0.0.1/ext/k/t_sens.cpp +184 -0
  391. crimlab-0.0.1/ext/k/t_sep.cpp +275 -0
  392. crimlab-0.0.1/ext/k/t_sev.cpp +82 -0
  393. crimlab-0.0.1/ext/k/t_sk.cpp +150 -0
  394. crimlab-0.0.1/ext/k/t_skch.cpp +49 -0
  395. crimlab-0.0.1/ext/k/t_sp2.cpp +296 -0
  396. crimlab-0.0.1/ext/k/t_spc.cpp +31 -0
  397. crimlab-0.0.1/ext/k/t_spi.cpp +144 -0
  398. crimlab-0.0.1/ext/k/t_spt.cpp +214 -0
  399. crimlab-0.0.1/ext/k/t_sreg.cpp +189 -0
  400. crimlab-0.0.1/ext/k/t_stm.cpp +219 -0
  401. crimlab-0.0.1/ext/k/t_svg.cpp +102 -0
  402. crimlab-0.0.1/ext/k/t_svt.cpp +114 -0
  403. crimlab-0.0.1/ext/k/t_swt.cpp +323 -0
  404. crimlab-0.0.1/ext/k/t_tab.cpp +105 -0
  405. crimlab-0.0.1/ext/k/t_tfr.cpp +297 -0
  406. crimlab-0.0.1/ext/k/t_thr.cpp +145 -0
  407. crimlab-0.0.1/ext/k/t_tlv.cpp +278 -0
  408. crimlab-0.0.1/ext/k/t_tox.cpp +159 -0
  409. crimlab-0.0.1/ext/k/t_tph.cpp +169 -0
  410. crimlab-0.0.1/ext/k/t_trj.cpp +250 -0
  411. crimlab-0.0.1/ext/k/t_trn.cpp +141 -0
  412. crimlab-0.0.1/ext/k/t_wdq.cpp +36 -0
  413. crimlab-0.0.1/ext/k/t_xpl.cpp +111 -0
  414. crimlab-0.0.1/ext/k/t_xw.cpp +69 -0
  415. crimlab-0.0.1/ext/k/tab.cpp +268 -0
  416. crimlab-0.0.1/ext/k/tchk.h +217 -0
  417. crimlab-0.0.1/ext/k/tfr.cpp +298 -0
  418. crimlab-0.0.1/ext/k/thm.inc +248 -0
  419. crimlab-0.0.1/ext/k/thr.cpp +1079 -0
  420. crimlab-0.0.1/ext/k/tlv.cpp +153 -0
  421. crimlab-0.0.1/ext/k/tox.cpp +119 -0
  422. crimlab-0.0.1/ext/k/tph.cpp +290 -0
  423. crimlab-0.0.1/ext/k/tps.cpp +81 -0
  424. crimlab-0.0.1/ext/k/trj.cpp +317 -0
  425. crimlab-0.0.1/ext/k/trn.cpp +262 -0
  426. crimlab-0.0.1/ext/k/trs.cpp +108 -0
  427. crimlab-0.0.1/ext/k/tsd.cpp +1080 -0
  428. crimlab-0.0.1/ext/k/txt.cpp +119 -0
  429. crimlab-0.0.1/ext/k/ver.h +6 -0
  430. crimlab-0.0.1/ext/k/vrfp.cpp +86 -0
  431. crimlab-0.0.1/ext/k/wcb.cpp +144 -0
  432. crimlab-0.0.1/ext/k/wdq.cpp +37 -0
  433. crimlab-0.0.1/ext/k/xls.h +150 -0
  434. crimlab-0.0.1/ext/k/xpl.cpp +309 -0
  435. crimlab-0.0.1/ext/k/xw.cpp +67 -0
  436. crimlab-0.0.1/ext/k/ynum.h +43 -0
  437. crimlab-0.0.1/pyproject.toml +37 -0
  438. crimlab-0.0.1/setup.cfg +4 -0
  439. crimlab-0.0.1/setup.py +95 -0
  440. crimlab-0.0.1/tests/data/ref.json +350 -0
  441. crimlab-0.0.1/tests/opt.py +135 -0
  442. crimlab-0.0.1/tests/ref.py +125 -0
  443. crimlab-0.0.1/tests/test_cli.py +105 -0
  444. crimlab-0.0.1/tests/test_edge.py +286 -0
  445. crimlab-0.0.1/tests/test_input.py +140 -0
  446. crimlab-0.0.1/tests/test_mem.py +216 -0
  447. crimlab-0.0.1/tests/test_misc.py +165 -0
  448. crimlab-0.0.1/tests/test_names.py +193 -0
  449. crimlab-0.0.1/tests/test_out.py +259 -0
  450. crimlab-0.0.1/tests/test_ref.py +40 -0
  451. crimlab-0.0.1/tests/test_svg.py +108 -0
crimlab-0.0.1/LICENSE ADDED
@@ -0,0 +1,71 @@
1
+ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
2
+
3
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+
5
+ 1. Definitions.
6
+
7
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
8
+
9
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
12
+
13
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
14
+
15
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
16
+
17
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
18
+
19
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
20
+
21
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
22
+
23
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
24
+
25
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
26
+
27
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
28
+
29
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
30
+
31
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
32
+
33
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
34
+
35
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
36
+
37
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
38
+
39
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
40
+
41
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
42
+
43
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
44
+
45
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
46
+
47
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
48
+
49
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
50
+
51
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
52
+
53
+ END OF TERMS AND CONDITIONS
54
+
55
+ APPENDIX: How to apply the Apache License to your work.
56
+
57
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
58
+
59
+ Copyright 2026 Vansh Singh Ruhela (rootcoder007)
60
+
61
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
62
+
63
+ http://www.apache.org/licenses/LICENSE-2.0
64
+
65
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
66
+
67
+ ---- LLVM Exceptions to the Apache 2.0 License ----
68
+
69
+ As an exception, if, as a result of your compiling your source code, portions of this Software are embedded into an Object form of such source code, you may redistribute such embedded portions in such Object form without complying with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
70
+
71
+ In addition, if you combine or link compiled forms of this Software with software that is licensed under the GPLv2 ("Combined Software") and if a court of competent jurisdiction determines that the patent provision (Section 3), the indemnity provision (Section 9) or other Section of the License conflicts with the conditions of the GPLv2, you may retroactively and prospectively choose to deem waived or otherwise exclude such Section(s) of the License, but only in their entirety and only with respect to the Combined Software.
@@ -0,0 +1,6 @@
1
+ graft ext
2
+ graft tests
3
+ include README.md LICENSE NOTICE
4
+ include crimlab/py.typed crimlab/*.pyi crimlab/_version.py crimlab/_thm.py
5
+ recursive-include crimlab/lean *.lean
6
+ global-exclude *.o *.so *.pyd __pycache__ *.py[cod] *.gcda *.gcno
crimlab-0.0.1/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ crimlab
2
+ Copyright 2026 Vansh Singh Ruhela (rootcoder007)
3
+
4
+ This product is licensed under the Apache License, Version 2.0, with
5
+ LLVM Exceptions (SPDX: Apache-2.0 WITH LLVM-exception); see LICENSE.
6
+ The R package carries the exceptions in its file LICENSE.note.
crimlab-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,378 @@
1
+ Metadata-Version: 2.4
2
+ Name: crimlab
3
+ Version: 0.0.1
4
+ Summary: Criminology and sociolegal statistics
5
+ Author: Vansh Singh Ruhela
6
+ License-Expression: Apache-2.0 WITH LLVM-exception
7
+ Project-URL: Homepage, https://github.com/rootcoder007/crimlab
8
+ Project-URL: Issues, https://github.com/rootcoder007/crimlab/issues
9
+ Classifier: Programming Language :: C++
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ License-File: NOTICE
17
+ Dynamic: license-file
18
+
19
+ # crimlab for Python
20
+
21
+ Criminology and sociolegal statistics: the Python package binds the same
22
+ compiled kernels as the R package crimlab (`../src`), with the same
23
+ function names, the same argument names and the same results. Every
24
+ number in the parity tests (`tests/data/ref.json`, written by
25
+ `dev/pyref.R` from the R package) is bit-for-bit what R returns; the
26
+ functions that reach the kernels through `clab_jrun()`, the JSON entry of
27
+ the command-line program, are checked against `../cli/test.tsv`
28
+ (`dev/clref.R`) to 1e-12.
29
+
30
+ The package imports nothing outside Python's standard library: no
31
+ runtime dependencies, no optional ones. Results are dicts of its own that
32
+ print as R prints them, export themselves as CSV or JSON, and (tables)
33
+ sort, filter and join; the two plots draw themselves as SVG, by the same
34
+ compiled code every binding can use.
35
+
36
+ ## Install
37
+
38
+ From a clone of the repository (a C++17 compiler is needed):
39
+
40
+ pip install ./py
41
+
42
+ The CI workflow (`.github/workflows/py.yml`) also builds wheels (one per
43
+ platform, stable ABI, Python 3.10 and later) and an sdist as workflow
44
+ artifacts. The package is not published on PyPI.
45
+
46
+ ## Examples
47
+
48
+ Disparity:
49
+
50
+ ```python
51
+ >>> from crimlab import vodtst, dspbm
52
+ >>> vodtst(day={"white": 600, "black": 400}, night={"white": 700, "black": 300})
53
+ group ref shday shnight ratio sign
54
+ 1 white TRUE 0.6 0.7 1.000000 -1
55
+ 2 black FALSE 0.4 0.3 1.555556 1
56
+
57
+ >>> dspbm(pop={"a": 9000, "b": 1000}, contact={"a": 900, "b": 300},
58
+ ... force={"a": 9, "b": 6})["rd"]
59
+ [1.0, 6.0]
60
+
61
+ ```
62
+
63
+ Forensics:
64
+
65
+ ```python
66
+ >>> from crimlab import gtmp, cllrmin, kinidx
67
+ >>> round(gtmp(p={"D3": 0.1, "vWA": 0.2}, q=[0.3, None], hom=[False, True],
68
+ ... theta=0.03)["log10lr"], 4)
69
+ 2.3068
70
+ >>> kinidx({"D3": [12, 14]}, {"D3": [12, 14]}, {"D3": [0.1, 0.2]}, rel="sibling")["locus"]
71
+ locus idx
72
+ 1 D3 8.375
73
+ >>> cllrmin([50, 200, 8], [0.01, 0.2, 1.5])
74
+ cllr min cal
75
+ 0.3008346 0.0000000 0.3008346
76
+
77
+ ```
78
+
79
+ Policing:
80
+
81
+ ```python
82
+ >>> from crimlab import clrsmp, expbnd
83
+ >>> clrsmp(clra={"minor": 90, "serious": 20}, reca=[100, 50],
84
+ ... clrb=[19, 60], recb=[20, 140])["total"]["simpson"]
85
+ 2.0
86
+ >>> expbnd(y={"white": 100, "black": 300}, m=[1000, 1000], gamma=1.5)["sign"]
87
+ [0, 1]
88
+
89
+ ```
90
+
91
+ Corrections:
92
+
93
+ ```python
94
+ >>> from crimlab import incap, sntbnd
95
+ >>> incap(lam={"low": 2, "high": 10}, q=0.1, s=1, share=[0.8, 0.2])["group"]
96
+ ['low', 'high', 'all']
97
+ >>> sntbnd([1, 0, 1, 1, 0, 0], ["a", "a", "b", "b", "b", "a"], treat="b")["term"]
98
+ ['a', 'b', 'effect']
99
+
100
+ ```
101
+
102
+ Proofs and the self-test:
103
+
104
+ ```python
105
+ >>> from crimlab import proof, selftest
106
+ >>> proof("orrisk")["theorem"][0]
107
+ 'Crimlab.RelRisk.or_eq_rr_mul'
108
+ >>> selftest()["nfail"]
109
+ 0
110
+
111
+ ```
112
+
113
+ ## Results
114
+
115
+ | R | Python |
116
+ |---|---|
117
+ | data frame | `Table`: a dict of columns (lists), in R's column order |
118
+ | named numeric vector | `Vector`: a dict of floats |
119
+ | list | `Record`: a dict of results |
120
+ | `NA` | `None` |
121
+ | `NaN`, `Inf` | `float("nan")`, `float("inf")` |
122
+
123
+ Each is still the dict it was (`r["ratio"]`, `dict(r)`, `r.items()` work
124
+ as for any dict) and prints as R prints it: a table with row numbers
125
+ first, numbers to 7 significant digits, a long table cut to its first 10
126
+ and last 5 rows with the row count; a vector with names above values; a
127
+ record part by part under `$name`. A `Table` also has:
128
+
129
+ - `shape`, `rows()` (a list of dicts), `row(i)`;
130
+ - `csv()`: RFC 4180 text, CRLF line ends, numbers in full (the shortest
131
+ text that reads back to the same double), None as an empty field, NaN
132
+ and the infinities as `NaN`, `Inf`, `-Inf`, bools as `TRUE`, `FALSE`;
133
+ - `json()` (also on `Vector` and `Record`): None is `null`; NaN and the
134
+ infinities, which JSON has no numbers for, are the strings `"NaN"`,
135
+ `"Inf"` and `"-Inf"`;
136
+ - `sort(by, desc=False)`: by a column or a list of them; stable; `desc` one
137
+ bool or one per column; None and NaN last either way; text by code point,
138
+ numbers (bools as 0 and 1) numerically; text and numbers in one column is
139
+ an error;
140
+ - `filter(f=None, **conds)`: `col=(op, value)` with op one of `==`, `!=`,
141
+ `<`, `<=`, `>`, `>=`, `in` (value a list), `col=value` for `==`, and f a
142
+ function of a row (a dict); conditions combine with and; a missing value
143
+ never passes; an unknown column or operator is an error;
144
+ - `join(other, on, how="inner")`: with another table or any dict of
145
+ equal-length columns, on one key column or a list; `how` is inner, left,
146
+ right or full. Keys match by exact equality, text with text, numbers with
147
+ numbers (1 with 1.0), bools with bools; a missing key (None or NaN)
148
+ matches nothing. Rows come in this table's order, each with its matches
149
+ in the other's order, then the other's unmatched rows (right, full); a key
150
+ on n rows here and m there gives n * m rows; unmatched cells are None.
151
+ Columns: the keys once, then this table's, then the other's; a name in
152
+ both that is not a key gets `.x` here and `.y` there. Hash-based, linear
153
+ time.
154
+
155
+ Each returns a new table and leaves the first unchanged. There is no
156
+ `select`: a dict comprehension is one, `Table({k: t[k] for k in cols})`.
157
+
158
+ ```python
159
+ >>> from crimlab import expbnd
160
+ >>> r = expbnd(y={"a": 100, "b": 300, "c": 7}, m={"a": 1000, "b": 1000, "c": 70},
161
+ ... gamma=1.5)
162
+ >>> r.filter(ratio=(">", 1)).sort("rate", desc=True)
163
+ group ref rate lo hi ratio rlo rhi sign
164
+ 1 b FALSE 0.3 0.2 0.45 3 1.333333 6.75 1
165
+ >>> r.csv().splitlines()[1]
166
+ 'a,TRUE,0.1,0.06666666666666667,0.15000000000000002,1.0,0.4444444444444444,2.25,0'
167
+
168
+ ```
169
+
170
+ ## Plots
171
+
172
+ `tipplt()` and `eceplt()` return the data of the plot. Their result has
173
+ `svg()`, which returns the plot as a standalone SVG document: axes with
174
+ tick labels, the curves, a legend, a title and axis labels; text as text
175
+ (a system sans-serif stack) and colours that read on light and dark
176
+ backgrounds; the same bytes on every machine. A method, not a file
177
+ argument: the result stays data first, the picture is asked for when it is
178
+ wanted, and where it goes (a file, a web page, a notebook) is the
179
+ caller's choice, with no paths or file handling in the package.
180
+
181
+ ```python
182
+ >>> from crimlab import tipplt
183
+ >>> svg = tipplt([50, 200, 8, 0.5], [0.01, 0.2, 1.5, 0.001]).svg()
184
+ >>> svg.splitlines()[1][:40]
185
+ '<svg xmlns="http://www.w3.org/2000/svg" '
186
+
187
+ ```
188
+
189
+ ![A Tippett plot drawn by crimlab](tipplt.svg)
190
+
191
+ ## Optional packages (never required)
192
+
193
+ NumPy, pandas and matplotlib are never imported by crimlab, but work with
194
+ it through their own generic protocols:
195
+
196
+ ```python
197
+ import numpy, pandas
198
+ vodtst(numpy.array([600.0, 400.0]), [700, 300]) # an array as input, zero copy
199
+ pandas.DataFrame(vodtst({"w": 600, "b": 400}, {"w": 700, "b": 300})) # a result as a frame
200
+ plt.step(t["same"]["log10lr"], t["same"]["share"], where="post") # t = tipplt(...)
201
+ ```
202
+
203
+ A pandas Series is read as its values, by position; for its index as group
204
+ names, pass `dict(s)`. A DataFrame is a table of rows by
205
+ `df.to_dict("index")` (a mapping of mappings).
206
+
207
+ ## Inputs
208
+
209
+ **Numbers** are one number (Python has no vector of one), a sequence
210
+ (list, tuple, `array.array`, `memoryview`, `range`) or an array: any
211
+ object with `__array_interface__` (a NumPy array, for one). An array of
212
+ contiguous float64 is read in place, without a copy; other numeric types
213
+ (float32, any integer type), strided arrays and object arrays are
214
+ converted; an array whose byte order is not the machine's is read as a
215
+ sequence when it is one. A 2-D array with one row or one column is the
216
+ vector it holds; an array with more than one dimension above 1 is refused
217
+ with R's message ("must be a vector, not a matrix ..."). A nested list is
218
+ not flattened: it is refused as not numbers.
219
+
220
+ Not numbers (TypeError): text, bytes, bools (as in R, a logical is not a
221
+ number), dates, complex numbers, dicts and sets where numbers are expected,
222
+ iterators and generators, nested sequences.
223
+
224
+ **Missing values** are `None` and `float("nan")`, both read as R's `NA`.
225
+ Where R refuses `NA` they are refused with R's message (ValueError); where
226
+ R accepts it (`q` at a homozygous locus of `gtmp()`, `y` for a detained
227
+ defendant in `sellab()`), so does Python.
228
+
229
+ **Logical** arguments (`hom`, `rel`, `rule`) take bools (any type named
230
+ `bool`, so NumPy's too), one or a sequence or a bool array; numbers are
231
+ refused as in R.
232
+
233
+ **Labels** (the sentences `z` of `sntbnd()`, alleles) are text, numbers or
234
+ bools, written as R's `as.character()` writes them: `2.0` is `"2"`,
235
+ `0.1 + 0.2` is `"0.3"`, `1e5` is `"1e+05"`, `True` is `"TRUE"`.
236
+
237
+ **Named values** are a mapping (dict) from name to value, or, where a name
238
+ repeats (which a dict cannot hold), a list of `(name, value)` tuples:
239
+ `[("a", 1), ("a", 2)]`.
240
+
241
+ **Tables** (`count` of `dyadrt()`, genotypes, `freq`, the one-table form of
242
+ `vodtst()`) are a sequence of rows, a 2-D array, or a mapping from row name
243
+ to row; a row is a sequence, or a mapping from column name to value (every
244
+ row naming the same columns), so a table with row and column names is a
245
+ mapping of mappings: `{"a": {"a": 640, "b": 160}, "b": {"a": 100, "b": 40}}`.
246
+ Row names that repeat: a list of `(row name, row)` tuples. Genotypes have
247
+ two columns, one row per locus; two values are one locus.
248
+
249
+ ## Names
250
+
251
+ Names are the identity of a group, under the rule of the R package
252
+ (`src/bind.cpp`, `align()`). An argument is named when it is a mapping
253
+ (dict) or a list of `(name, value)` tuples; a table names its rows when it
254
+ is a mapping (see Inputs).
255
+
256
+ - All the arguments of a call that hold one value per group (or per unit,
257
+ per locus, per arm) named, with the same names: each is matched to the
258
+ first by name, in any order. `vodtst({"a": 6, "b": 4}, {"b": 5, "a": 5})`
259
+ pairs `a` with `a`.
260
+ - All named, with different names: an error that lists them,
261
+ ``vodtst: `night` must name the same groups as `day`; missing: b; extra: c.``
262
+ - Some named, some not: positions, as given. Only names protect against a
263
+ mismatch.
264
+ - A name given twice in a per-group argument is an error
265
+ (``vodtst: `day` names a group twice: a.``); in a per-unit argument
266
+ (`outtst()`, `lrpost()`, `rtmhs()`, `sellab()`, `sntbnd()`) it leaves
267
+ positions in use.
268
+ - Only arguments of the length of the first take part: one value to be
269
+ recycled keeps its place.
270
+ - The groups are named by the first argument that names them, else `"1"`,
271
+ `"2"`, ...; the output keeps the order of the first argument. `ref` is a
272
+ position from 1 in that order when it is a number, a group name
273
+ otherwise, and is never chosen by sorting; `vodtst()`, `dspbm()` and
274
+ `expbnd()` mark it in their `ref` column.
275
+ - `vodtst(day=table)`: with `night` left out, `day` is one table whose two
276
+ columns are named `day` and `night`: a dict of the two columns, or a
277
+ mapping from group to `{"day": ..., "night": ...}`.
278
+ - `dyadrt()`: a `count` that names its rows and its columns (a mapping of
279
+ mappings) has
280
+ its columns matched to its rows by name, and both to `pop` when `pop` is
281
+ named.
282
+ - Genotype tables and `freq` that all name their loci are matched by locus
283
+ to the first.
284
+ - `hzdsel()`: `surh` and `surl` both named `control` and `treated`, in
285
+ either order, are read by name; otherwise the first value is the control
286
+ arm.
287
+ - `impfpr()`: `p`, `ppv` and `fnr`, when every one given names its values,
288
+ with names that do not repeat and one length, are matched to the first
289
+ by name (an error names a unit missing from a later one); otherwise
290
+ positions. The result is named by the first argument of its length that
291
+ is named.
292
+
293
+ ## Errors
294
+
295
+ Errors are exceptions whose message is R's, word for word, starting with
296
+ the function's name: `ValueError` for a value outside what the function
297
+ takes (missing, not finite, out of range, wrong length), `TypeError` for an
298
+ argument of the wrong kind. A failed allocation is a `MemoryError`.
299
+
300
+ ## Differences from R
301
+
302
+ 1. `orrisk()`'s first argument is `or`, as in R, but `or` is a Python
303
+ keyword: give it by position, or as `orrisk(**{"or": 3}, rate=0.4,
304
+ share=0.5)`.
305
+ 2. Results are dicts of the package's own classes (see Results). An
306
+ unnamed result of one number is a float for `cllr()`; `lrpost()` always
307
+ returns a list; `impfpr()` returns a list when no argument names its
308
+ values; `lrcal()` returns a `Record` of two lists.
309
+ 3. R's forms of a named vector (a 1-d table, a list of single numbers, a
310
+ one-row data frame) are a dict, or a list of `(name, value)` tuples, in
311
+ Python; a matrix with row and column names is a mapping of mappings.
312
+ 4. `ref`: a bool or None is refused with a TypeError; a number is always a
313
+ position, so a group named by a number cannot be chosen by name. R
314
+ reads a factor `ref` by its label; Python has no one-value categorical.
315
+ 5. `tipplt()` and `eceplt()` return the plotted data and draw nothing; the
316
+ picture is `svg()` on the result (R draws on the current device with
317
+ base graphics and returns the data invisibly).
318
+ 6. None and NaN are both R's `NA` on input. On output R's `NA` is None and
319
+ `NaN` is NaN.
320
+ 7. A nested list where a vector is expected is refused as not numbers
321
+ (TypeError); R's message for a matrix is given for arrays with more
322
+ than one dimension above 1. For the allele names of `mixlr()` a 2-D
323
+ array is refused as not names of `p`.
324
+ 8. `treat` in `sntbnd()` must be one label; a list, even of one label, is
325
+ refused (R accepts a vector of length 1). The default (True for bools,
326
+ 1 for numbers 0 and 1) follows R.
327
+ 9. A one-row genotype table is named `"1"` unless it is named (mapping
328
+ key); R names a one-row matrix by its only column name when it has
329
+ column names but no row names. Column names that repeat cannot be
330
+ given as a mapping; such a table is given by position.
331
+ 10. `proof()`: `None` means every function (R's `NULL`); R's `NA` has no
332
+ Python spelling, and `[None]` is refused.
333
+ 11. When several arguments are wrong at once the first error reported may
334
+ differ: names and labels are checked in Python before the numbers are
335
+ checked in the compiled module.
336
+ 12. R conditions carry a call; Python exceptions have none.
337
+ 13. `selftest()` is exported (R runs the self-test through an internal
338
+ `.Call`).
339
+ 14. R-only kinds of input have no counterpart: `"bytes"`-encoded strings,
340
+ classed numbers with units, labelled vectors (R refuses them with a
341
+ message of its own), factors, environments.
342
+ 15. Tables print with R's layout but are not R's printing in every detail
343
+ (column widths, the choice between fixed and scientific per column).
344
+ 16. The functions that go through `clab_jrun()` (most of those added
345
+ after the first ones; `crimlab._j` holds them) take JSON-like
346
+ values: numbers, text and bools, lists, and dicts for named vectors,
347
+ data frames (a dict of columns) and lists. A matrix is a list of its
348
+ rows, also in results; numbers in results are floats. An R name that
349
+ is a Python keyword takes a final underscore (``from_``,
350
+ ``lambda_``). Labels are sorted as text where R would keep a factor's
351
+ level order. A function whose result is random needs `seed` (R draws
352
+ one from its own generator when it is left out). A warning R gives is
353
+ returned in the result as ``warnings``, a list of its messages, not
354
+ raised; attributes R sets beside a result (a class, a centre) are not
355
+ returned, nor the row and column names of a matrix.
356
+
357
+ ## Development
358
+
359
+ From the repository root:
360
+
361
+ pip install ./py pytest
362
+ cd py/tests && python -m pytest # pytest only, nothing else
363
+ python -m pytest opt.py # NumPy, pandas, matplotlib, if installed
364
+ python -m pytest --doctest-modules --pyargs crimlab
365
+ Rscript dev/pyref.R LIB # regenerate tests/data/ref.json from R
366
+
367
+ `setup.py` copies the kernel sources (`../src/*.cpp` and `*.h` that do not
368
+ include R), the version (`../DESCRIPTION`), the proof table
369
+ (`../src/bind.cpp`), the Lean files (`../inst/lean`) and the licence into
370
+ `py/` before every build; those copies are build output and are not
371
+ committed. An sdist carries them and builds on its own.
372
+
373
+ Adding a function: its entry point in `ext/clab.cpp` (one function and one
374
+ line in the method table), its wrapper with a docstring in `crimlab/`, its
375
+ name in `__all__` and `_clab.pyi`, and its cases in `dev/pyref.R`.
376
+
377
+ A documentation site is left to the maintainer; the docstrings follow the
378
+ numpydoc layout, so Sphinx with `numpydoc` or `napoleon` can render them.