diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-12 16:57:28 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-12 16:57:28 +0000 |
| commit | 99a92f8060e76da0357a30df746c70081646bd28 (patch) | |
| tree | 7f66683ea529e6b73b3381642456a0294f44aa34 /test | |
| parent | 84ad4d1e3f96ad45fdf3d72abfbcf516802e4532 (diff) | |
| download | gn-bnw-main.tar.gz | |
BNW's computation does not need the web application: run.sh drives three C
programs over files in a per-run directory, and everything above that is file
assembly and rendering. bin/bnw does the same pipeline -- network_score, the
k-best search, structure -- in a private working directory, and reports one row
per candidate edge with its posterior and whether it survived the threshold.
The reference for all of it is the running bnw-container, not a memory of it:
its six continuous traits example was run through the web application
(bn_genenet.php -> execute_bn_gom.php) and the resulting files kept as fixtures
in test/golden/. test/parity_check.py compares our continuous_input.txt and
structure_input.txt against those, and the driver's own stdout against the
file. Today: byte-identical, 5 edges.
Four things that run settled, each of which had been guessed wrong or not at
all:
* continuous_input.txt is header, then a TYPE LINE (1 = continuous, n =
n-level discrete), then data. network_score reads the type before the
data, and the web application's file is one line longer than the matrix
because of it. Without the line the first data row shifts and
network_score segfaults.
* structure exits with an uninitialised status while writing a correct file.
The web application ignores the status; the driver now judges it by its
output and only fails if the file is missing.
* get_kbest_nets.cc used SGI's <ext/hash_set>, which modern libstdc++ no
longer has. It now uses std::unordered_set with an explicit hasher
(specialising std::hash for a pointer type is not allowed), and build.sh
compiles the C with -std=gnu89 because the sources predate C99.
* our run leaves postProbEachEdge.txt with per-edge posteriors; the web
application's flow leaves none behind, so the posteriors are information
the endpoint can report that the web app never showed.
Exit codes are part of the contract GN4 will code against: 0 ok, 2 bad input,
3 the computation failed, 77 the binaries are not installed (a conventional
skip, so a test suite can run where BNW is not).
Build output is gitignored. AI plan and status updated in
info_files/gn4-integration-plan.md; README gained a "Headless driver" section.
Diffstat (limited to 'test')
| -rw-r--r-- | test/golden/six_traits_continuous_input.txt | 202 | ||||
| -rw-r--r-- | test/golden/six_traits_matrix.tsv | 201 | ||||
| -rw-r--r-- | test/golden/six_traits_structure_input.txt | 7 | ||||
| -rwxr-xr-x | test/parity_check.py | 119 |
4 files changed, 529 insertions, 0 deletions
diff --git a/test/golden/six_traits_continuous_input.txt b/test/golden/six_traits_continuous_input.txt new file mode 100644 index 00000000..0f57b501 --- /dev/null +++ b/test/golden/six_traits_continuous_input.txt @@ -0,0 +1,202 @@ +Trait1 Trait2 Trait3 Trait4 Trait5 Trait6 +1 1 1 1 1 1 +0.46259 1.2692 -1.3164 -0.44096 0.5929 -0.75422 +-0.10011 -0.88834 1.6407 0.99972 0.31288 0.65602 +-1.0533 -0.55296 1.2715 1.3686 -0.19153 0.37361 +0.042371 0.13573 -0.72659 -0.66133 0.43157 -1.6715 +-0.68686 -1.6152 -0.95019 -1.2239 0.12319 -0.79155 +-0.4558 0.090877 0.94224 1.2354 -0.36356 0.34937 +0.237 -0.49002 1.8939 1.4399 0.033059 1.3229 +0.070265 0.22547 -1.4903 -0.069341 -0.16148 -0.01449 +-0.69146 -0.43461 1.1501 0.21205 -0.18087 0.32746 +0.31535 -0.9858 0.57816 0.35924 0.12866 1.0553 +1.2718 0.39314 0.6669 0.90002 -0.30206 1.3376 +1.1871 -0.45611 0.87227 0.31014 -0.092846 0.81278 +-1.0168 -0.44286 1.6933 0.72968 0.038808 0.81906 +-0.25313 0.52468 0.02823 -0.20984 -0.075809 -1.3591 +-0.58108 -0.3967 -0.11925 -0.61288 0.46778 0.090941 +-0.88043 -0.28187 -1.1645 -1.2543 -0.28951 -1.039 +0.54121 0.24395 -1.0043 -1.4483 -0.19839 -2.5407 +0.47375 1.1319 0.68553 1.035 0.44043 1.3011 +0.57785 0.69093 1.5941 1.6735 0.19981 0.50708 +-0.43989 0.0024131 -1.5405 -1.2304 -0.15382 -1.1058 +0.38035 -0.063535 1.1606 1.3124 -0.38043 0.6277 +0.70114 -0.41044 -0.39767 -1.5424 0.27477 -0.76183 +-0.9406 -0.20526 1.3302 1.097 0.16006 1.2988 +0.52122 0.064793 -0.031492 0.21696 -0.41979 -0.79123 +-0.53387 -0.71043 -0.52344 -1.5584 -0.09538 -1.5781 +0.49563 -0.58126 0.7747 1.274 0.19196 0.10624 +1.1499 1.879 0.43595 0.73474 0.045381 -0.88645 +0.40705 -0.37647 -0.19815 -1.5366 0.37167 -0.10553 +0.62526 0.043371 -0.64449 -0.44076 -0.4318 -0.91807 +-0.61788 -0.62414 0.3169 0.85091 -0.10135 0.79065 +0.18491 -1.5226 1.1149 0.75046 0.25948 0.42431 +0.86063 0.92883 -1.1584 -0.099858 -0.55095 -0.064129 +-0.28946 0.0057533 -0.95703 -0.44018 0.084268 -0.23718 +-0.073096 0.16452 1.4444 1.1452 0.46025 0.30452 +0.15637 -0.73137 0.585 -0.046911 0.43881 1.2888 +0.081142 -0.63691 -0.14883 0.66593 -0.13479 -0.22207 +0.10876 -0.23383 1.8314 1.3282 0.4362 0.90139 +-1.0582 -0.97152 -0.57118 -1.2617 0.17115 -0.060679 +-0.47421 -0.56819 -0.38775 0.035215 0.51982 -1.6309 +-0.10242 0.8127 0.41773 -1.1308 -0.30719 -0.80758 +-0.083462 -0.4565 1.1556 0.3299 0.087362 0.31349 +-0.98158 0.01727 -1.3281 -1.4474 0.54555 -0.10096 +-0.80604 -0.19415 1.4986 1.3386 -0.16367 0.68271 +0.80082 -0.57853 1.0716 0.94015 -0.54114 0.032172 +2.0456 0.97954 -0.45536 -0.14332 -0.25819 -1.0833 +-0.30148 0.20623 0.64194 0.76414 -0.59067 0.64326 +-0.55625 -0.26957 1.8447 1.6568 -0.38077 0.58831 +0.11898 0.80706 -0.025844 -0.57984 -0.23395 -1.1554 +-0.095497 -1.0637 -0.92583 -0.57928 0.23695 -0.42992 +0.066154 0.73037 -0.73622 -0.57047 0.39169 0.40928 +0.81522 0.11381 0.68971 0.29219 0.037792 0.81502 +-0.65356 -0.20182 0.92089 0.92298 -0.5417 0.49215 +-0.90826 -0.10979 1.3847 0.75954 -0.20255 0.32975 +-0.25671 -1.1903 -1.4241 -1.6058 -0.062549 -1.3981 +-1.8038 -1.4801 -0.94121 -1.6244 0.4817 -0.0029469 +0.12651 0.028719 -1.5818 -1.0266 0.19779 -0.36357 +-1.0658 -0.58443 0.68956 0.35467 0.11177 1.5243 +0.14729 -0.15111 -0.027639 -0.2899 0.11533 -0.60305 +-0.76889 0.87161 -0.83556 -1.1777 -0.21878 -0.98527 +0.12252 0.49068 -0.2557 -1.5816 0.25332 -0.78715 +-0.40287 0.26456 0.62208 0.60909 0.36074 0.092703 +-0.78301 1.4641 1.3162 1.9448 -0.10841 0.9618 +-0.25018 -0.32797 -1.113 -1.6123 0.6272 -1.2718 +0.15804 -0.18147 2.4571 0.59504 -0.34056 0.8691 +-0.582 0.25738 1.4075 0.92251 -0.40889 0.66381 +-0.26827 0.58632 0.51883 1.5745 -0.13818 1.0526 +0.13453 0.18218 -0.51676 -0.54166 -0.36636 -1.206 +1.1502 0.36164 1.9983 1.0809 0.11272 0.67683 +0.27812 0.46559 -1.6109 -0.91039 0.3803 -0.71802 +0.15292 0.61921 0.71009 1.3063 -0.35819 0.8661 +0.19902 0.48986 -1.4026 -0.8495 0.47158 0.0622 +0.4838 1.1096 1.4392 1.1438 0.34739 0.084004 +-0.63609 -0.35105 0.63581 1.1939 -0.062938 0.91353 +0.64203 -0.5095 -1.7792 -0.88803 0.43482 -0.66314 +-0.18434 -0.48157 0.69942 0.56942 -0.019967 0.50506 +0.10168 -1.0928 1.2144 0.28313 0.22159 0.54058 +-0.18578 -0.45336 1.5468 0.99679 0.11821 1.0476 +-0.60607 -1.1275 -0.90963 -0.69014 -0.33163 -1.2734 +-0.35353 -0.42708 0.78989 0.14094 -0.056632 0.80598 +-0.020221 -1.1235 1.9782 -0.041281 0.19857 1.2488 +1.2346 -0.37121 1.3325 1.1237 -0.027458 1.0044 +-0.54489 1.6812 -0.59836 -0.012441 0.41243 -0.58835 +-0.029577 2.1707 1.3285 1.2109 0.29684 0.90646 +0.70774 1.0606 -1.3996 -0.020914 -0.60955 -1.2187 +0.07926 0.52862 1.3994 0.54549 0.55303 0.16155 +0.041856 -0.92023 0.87269 -0.66601 -0.15945 0.1004 +0.17665 0.31945 -1.7756 -0.60442 0.020525 -1.0625 +-0.090238 -0.65111 0.56993 -0.4117 -0.19486 -0.18849 +0.059166 -0.47194 -0.69068 -0.41022 0.25867 -0.057175 +0.10473 0.66887 0.082035 -0.55975 -0.28439 -1.468 +-0.20937 -0.36621 0.09609 0.28164 0.24673 -0.11107 +-1.2678 0.22369 -0.42201 -0.70103 0.075915 -1.3347 +-0.35467 0.11166 -0.42144 -0.095223 -0.29936 -0.68322 +0.84875 1.24 -0.81217 0.084034 -0.32224 -1.6241 +-0.45939 1.3208 0.97993 1.2991 -0.015791 1.487 +-0.42254 -0.57928 -0.58529 -2.2375 0.51999 -0.79909 +0.32092 -0.13796 0.67098 0.24639 -0.36066 -0.032948 +-1.2408 -0.94836 0.026276 -0.37981 -0.02237 -0.38777 +0.20959 2.1466 -1.7027 -1.3169 -0.16515 -1.046 +-0.10482 1.3773 -1.2998 -0.014223 0.34065 -0.35362 +-0.66188 -1.2477 -0.62084 0.27682 0.1674 -0.8918 +-0.97246 -0.73017 1.3843 1.5549 0.1067 0.85754 +0.74567 -0.032694 1.1153 0.97318 -0.0033905 0.85059 +0.29324 -0.090608 -0.4945 -1.0484 -0.14987 -1.0141 +-0.86818 0.44948 1.8531 0.51896 -0.021141 1.8486 +0.362 -0.29749 -0.66525 0.21709 -0.15594 -1.4087 +-0.17675 0.36465 -0.45423 -1.262 0.22968 -1.246 +-0.34633 -0.16067 -1.2216 -1.3019 -0.040891 -1.2935 +0.44608 -0.57732 0.25606 -1.1664 0.54705 -0.19859 +0.45398 -0.55214 -0.33433 -0.085418 -0.10094 -0.48509 +0.12407 0.022419 -1.0312 -0.47727 0.20924 -1.2961 +-0.76644 -1.1794 1.2345 0.84756 0.1532 0.77648 +-0.10329 -0.53768 -0.67677 -0.58708 -0.014634 -0.036347 +0.2378 0.15372 0.49652 0.29193 0.19047 1.152 +0.024605 -0.38937 -0.89907 -0.42106 0.16921 -0.80893 +0.28812 0.26265 -0.94234 -0.88527 -0.49803 0.48254 +0.85086 0.11783 1.5014 1.2382 0.24441 1.3649 +0.86172 0.14894 -0.4846 -1.3488 -0.41844 -1.1372 +0.67971 -0.27488 -0.50687 -0.79153 -0.093399 -1.391 +-0.91977 -0.66099 0.5801 0.46587 -0.2263 1.43 +0.88213 -0.48674 -0.42406 -1.2762 0.28981 -1.0813 +-0.36583 0.51518 1.4491 1.4995 -0.073755 1.1218 +-0.54006 -0.59443 0.81263 0.65809 -0.15621 1.2508 +1.2125 -0.012648 -0.92657 -0.81972 -0.1536 -1.0176 +0.42493 0.34558 -1.7672 -1.3503 -0.045928 0.37449 +0.17097 -0.86593 -0.13424 1.0257 0.058014 0.91044 +-1.393 0.5338 1.8514 2.291 0.15305 0.30028 +-0.58552 -1.5337 1.5133 0.9976 0.64638 1.4428 +0.046272 -0.56387 -0.86063 -1.0462 0.014457 -1.3038 +0.34933 -0.16796 -0.27854 -0.27327 -0.0040928 -0.17912 +-1.0672 0.3979 1.208 0.50111 -0.013978 0.015097 +0.31052 -0.46723 -1.1237 0.59267 0.30978 -1.0169 +-0.55337 -0.42776 -0.12612 -0.41838 -0.56558 -0.58189 +0.3925 0.15644 -0.72963 -0.66601 -0.10837 -0.27787 +-0.48513 -1.4119 -0.16889 -0.19646 -0.068098 -0.084247 +0.16692 1.5447 -1.3064 -1.3338 -0.25668 -0.48832 +-0.36092 0.31518 -0.44815 -1.4019 -0.47505 -0.37187 +-1.8192 -0.57745 1.1304 0.262 -0.3595 0.58577 +-0.065383 0.07156 1.4931 2.3215 0.85149 1.4585 +-1.119 0.70896 1.0498 0.74334 0.75838 1.6107 +-0.17682 -0.21029 -0.74465 -0.83806 0.10827 -1.2829 +0.69834 -0.082402 0.64008 -0.83119 -0.26766 0.36961 +-0.28266 1.1929 -0.15174 0.098554 -0.33989 -0.6376 +1.5369 1.8434 0.0030761 -0.59703 0.14497 -1.5165 +0.35023 -0.28475 -0.93594 -1.0937 -0.46614 -2.188 +0.62308 1.0873 -0.0037182 0.86847 -0.48699 -0.10105 +-1.0408 -0.99866 2.0799 1.1634 0.092516 0.30401 +-0.87125 -0.88987 1.0278 1.0157 -0.23725 1.2377 +-0.020591 -0.03398 -0.024834 -1.3588 -0.045961 -0.89693 +0.9213 -0.57037 1.044 1.2994 0.046517 0.66563 +-0.87288 -0.96382 -0.704 -1.2184 0.046903 -0.30008 +0.77586 -0.34168 -0.09867 -0.37744 -0.24309 -0.13441 +0.19521 0.67595 1.4533 1.5115 0.19553 0.79596 +-1.3273 1.0891 1.2544 0.98928 0.045725 0.54963 +0.59176 0.65915 -0.84578 -0.080229 -0.26961 0.24045 +-0.66958 -1.042 -1.2138 -0.7612 -0.22775 -0.40062 +1.1154 -0.57069 -0.6592 -2.1961 -0.013175 0.46007 +-0.5254 0.0031225 -0.77758 0.8169 0.13224 -0.65572 +0.24551 1.5078 0.10719 1.1454 0.70578 0.59051 +0.29875 -0.11455 -1.0497 -0.77881 0.080708 -0.48337 +-0.1047 0.011628 1.2504 0.41776 -0.20102 1.2252 +0.44808 -0.8165 -0.080134 -0.49618 0.051011 -0.71722 +2.0365 1.5592 1.3257 1.2472 -0.47899 0.10943 +-0.16507 -0.66011 0.98739 0.58519 0.245 -0.43277 +-0.028366 -0.16961 -1.3266 0.14248 -0.24634 -1.1154 +0.92842 1.8842 1.3169 1.0358 -0.20988 0.88021 +0.33158 0.32463 -0.50924 0.40233 0.54391 -0.24309 +1.2555 0.1928 -0.487 0.048779 -0.23483 -1.477 +0.75021 0.85943 -0.2323 0.10748 -0.68906 0.84276 +0.6297 1.7397 -1.6136 -0.43268 -0.21442 -0.77462 +0.53168 1.0807 1.0853 0.62304 0.44036 0.48087 +-0.31256 -0.69771 -0.88556 -1.333 0.038614 -1.5744 +-0.039695 -0.52447 0.91401 -0.93272 0.53434 -0.080746 +-0.16596 0.56821 0.76008 0.45442 0.10286 0.6539 +-0.4331 -0.89669 -1.3097 -1.2157 0.1065 -0.8512 +-0.34708 -0.51457 -1.012 -0.39437 -0.55374 -1.144 +0.024082 0.7128 -1.3702 -1.4492 -0.10228 -0.59071 +-0.0037109 -0.68845 -0.649 -0.91581 0.066805 -0.98583 +0.68706 0.067424 0.87139 0.7938 -0.099645 1.529 +-0.31183 0.57814 -0.80815 -0.66724 -0.31919 -0.61319 +-0.11153 -0.6246 -0.27979 -0.18363 0.83639 0.014919 +0.20406 1.5838 -0.96334 -1.1228 -0.17808 -1.2123 +-0.1134 0.63358 -0.53321 -0.84276 -0.27657 -0.36992 +0.25517 0.67006 -0.1349 0.18275 0.40982 -0.62487 +-1.2684 0.31042 0.91155 0.66143 0.2483 -0.12434 +-0.97542 -0.85419 0.7663 0.16362 -0.18737 0.67266 +-0.043882 -0.62746 -0.82816 -0.40626 -0.051048 -0.61297 +0.59605 -0.45852 1.2962 0.78156 -0.48154 0.17778 +-0.06266 1.1144 -0.80524 -0.3189 -0.16038 -0.96372 +-1.1821 1.0798 -1.3407 -0.52643 0.12458 -0.7871 +0.59446 0.89186 -0.97856 -0.64658 0.2712 -1.5538 +0.15067 0.41827 -1.0487 -1.0551 0.19143 -1.4537 +-1.073 0.022587 -1.7088 -1.3777 0.1964 -0.84025 +0.20928 1.8026 1.2073 2.78 0.15131 0.3448 +-1.1317 -0.6359 -0.70457 -1.676 -0.22886 -0.58769 +-0.039428 -0.58746 0.56 0.7896 -0.052581 0.99511 +0.55023 -0.20403 0.138 -0.70518 0.66927 -0.28861 +0.57423 1.1886 0.092876 0.025677 -0.41099 -1.2858 +-0.14179 1.5827 -0.94328 0.7703 -0.43967 -0.50448 +0.14666 1.0492 -0.0030259 -0.62418 -0.087515 -0.048386 diff --git a/test/golden/six_traits_matrix.tsv b/test/golden/six_traits_matrix.tsv new file mode 100644 index 00000000..8ec75e79 --- /dev/null +++ b/test/golden/six_traits_matrix.tsv @@ -0,0 +1,201 @@ +Trait1 Trait2 Trait3 Trait4 Trait5 Trait6 +0.46259 1.2692 -1.3164 -0.44096 0.5929 -0.75422 +-0.10011 -0.88834 1.6407 0.99972 0.31288 0.65602 +-1.0533 -0.55296 1.2715 1.3686 -0.19153 0.37361 +0.042371 0.13573 -0.72659 -0.66133 0.43157 -1.6715 +-0.68686 -1.6152 -0.95019 -1.2239 0.12319 -0.79155 +-0.4558 0.090877 0.94224 1.2354 -0.36356 0.34937 +0.237 -0.49002 1.8939 1.4399 0.033059 1.3229 +0.070265 0.22547 -1.4903 -0.069341 -0.16148 -0.01449 +-0.69146 -0.43461 1.1501 0.21205 -0.18087 0.32746 +0.31535 -0.9858 0.57816 0.35924 0.12866 1.0553 +1.2718 0.39314 0.6669 0.90002 -0.30206 1.3376 +1.1871 -0.45611 0.87227 0.31014 -0.092846 0.81278 +-1.0168 -0.44286 1.6933 0.72968 0.038808 0.81906 +-0.25313 0.52468 0.02823 -0.20984 -0.075809 -1.3591 +-0.58108 -0.3967 -0.11925 -0.61288 0.46778 0.090941 +-0.88043 -0.28187 -1.1645 -1.2543 -0.28951 -1.039 +0.54121 0.24395 -1.0043 -1.4483 -0.19839 -2.5407 +0.47375 1.1319 0.68553 1.035 0.44043 1.3011 +0.57785 0.69093 1.5941 1.6735 0.19981 0.50708 +-0.43989 0.0024131 -1.5405 -1.2304 -0.15382 -1.1058 +0.38035 -0.063535 1.1606 1.3124 -0.38043 0.6277 +0.70114 -0.41044 -0.39767 -1.5424 0.27477 -0.76183 +-0.9406 -0.20526 1.3302 1.097 0.16006 1.2988 +0.52122 0.064793 -0.031492 0.21696 -0.41979 -0.79123 +-0.53387 -0.71043 -0.52344 -1.5584 -0.09538 -1.5781 +0.49563 -0.58126 0.7747 1.274 0.19196 0.10624 +1.1499 1.879 0.43595 0.73474 0.045381 -0.88645 +0.40705 -0.37647 -0.19815 -1.5366 0.37167 -0.10553 +0.62526 0.043371 -0.64449 -0.44076 -0.4318 -0.91807 +-0.61788 -0.62414 0.3169 0.85091 -0.10135 0.79065 +0.18491 -1.5226 1.1149 0.75046 0.25948 0.42431 +0.86063 0.92883 -1.1584 -0.099858 -0.55095 -0.064129 +-0.28946 0.0057533 -0.95703 -0.44018 0.084268 -0.23718 +-0.073096 0.16452 1.4444 1.1452 0.46025 0.30452 +0.15637 -0.73137 0.585 -0.046911 0.43881 1.2888 +0.081142 -0.63691 -0.14883 0.66593 -0.13479 -0.22207 +0.10876 -0.23383 1.8314 1.3282 0.4362 0.90139 +-1.0582 -0.97152 -0.57118 -1.2617 0.17115 -0.060679 +-0.47421 -0.56819 -0.38775 0.035215 0.51982 -1.6309 +-0.10242 0.8127 0.41773 -1.1308 -0.30719 -0.80758 +-0.083462 -0.4565 1.1556 0.3299 0.087362 0.31349 +-0.98158 0.01727 -1.3281 -1.4474 0.54555 -0.10096 +-0.80604 -0.19415 1.4986 1.3386 -0.16367 0.68271 +0.80082 -0.57853 1.0716 0.94015 -0.54114 0.032172 +2.0456 0.97954 -0.45536 -0.14332 -0.25819 -1.0833 +-0.30148 0.20623 0.64194 0.76414 -0.59067 0.64326 +-0.55625 -0.26957 1.8447 1.6568 -0.38077 0.58831 +0.11898 0.80706 -0.025844 -0.57984 -0.23395 -1.1554 +-0.095497 -1.0637 -0.92583 -0.57928 0.23695 -0.42992 +0.066154 0.73037 -0.73622 -0.57047 0.39169 0.40928 +0.81522 0.11381 0.68971 0.29219 0.037792 0.81502 +-0.65356 -0.20182 0.92089 0.92298 -0.5417 0.49215 +-0.90826 -0.10979 1.3847 0.75954 -0.20255 0.32975 +-0.25671 -1.1903 -1.4241 -1.6058 -0.062549 -1.3981 +-1.8038 -1.4801 -0.94121 -1.6244 0.4817 -0.0029469 +0.12651 0.028719 -1.5818 -1.0266 0.19779 -0.36357 +-1.0658 -0.58443 0.68956 0.35467 0.11177 1.5243 +0.14729 -0.15111 -0.027639 -0.2899 0.11533 -0.60305 +-0.76889 0.87161 -0.83556 -1.1777 -0.21878 -0.98527 +0.12252 0.49068 -0.2557 -1.5816 0.25332 -0.78715 +-0.40287 0.26456 0.62208 0.60909 0.36074 0.092703 +-0.78301 1.4641 1.3162 1.9448 -0.10841 0.9618 +-0.25018 -0.32797 -1.113 -1.6123 0.6272 -1.2718 +0.15804 -0.18147 2.4571 0.59504 -0.34056 0.8691 +-0.582 0.25738 1.4075 0.92251 -0.40889 0.66381 +-0.26827 0.58632 0.51883 1.5745 -0.13818 1.0526 +0.13453 0.18218 -0.51676 -0.54166 -0.36636 -1.206 +1.1502 0.36164 1.9983 1.0809 0.11272 0.67683 +0.27812 0.46559 -1.6109 -0.91039 0.3803 -0.71802 +0.15292 0.61921 0.71009 1.3063 -0.35819 0.8661 +0.19902 0.48986 -1.4026 -0.8495 0.47158 0.0622 +0.4838 1.1096 1.4392 1.1438 0.34739 0.084004 +-0.63609 -0.35105 0.63581 1.1939 -0.062938 0.91353 +0.64203 -0.5095 -1.7792 -0.88803 0.43482 -0.66314 +-0.18434 -0.48157 0.69942 0.56942 -0.019967 0.50506 +0.10168 -1.0928 1.2144 0.28313 0.22159 0.54058 +-0.18578 -0.45336 1.5468 0.99679 0.11821 1.0476 +-0.60607 -1.1275 -0.90963 -0.69014 -0.33163 -1.2734 +-0.35353 -0.42708 0.78989 0.14094 -0.056632 0.80598 +-0.020221 -1.1235 1.9782 -0.041281 0.19857 1.2488 +1.2346 -0.37121 1.3325 1.1237 -0.027458 1.0044 +-0.54489 1.6812 -0.59836 -0.012441 0.41243 -0.58835 +-0.029577 2.1707 1.3285 1.2109 0.29684 0.90646 +0.70774 1.0606 -1.3996 -0.020914 -0.60955 -1.2187 +0.07926 0.52862 1.3994 0.54549 0.55303 0.16155 +0.041856 -0.92023 0.87269 -0.66601 -0.15945 0.1004 +0.17665 0.31945 -1.7756 -0.60442 0.020525 -1.0625 +-0.090238 -0.65111 0.56993 -0.4117 -0.19486 -0.18849 +0.059166 -0.47194 -0.69068 -0.41022 0.25867 -0.057175 +0.10473 0.66887 0.082035 -0.55975 -0.28439 -1.468 +-0.20937 -0.36621 0.09609 0.28164 0.24673 -0.11107 +-1.2678 0.22369 -0.42201 -0.70103 0.075915 -1.3347 +-0.35467 0.11166 -0.42144 -0.095223 -0.29936 -0.68322 +0.84875 1.24 -0.81217 0.084034 -0.32224 -1.6241 +-0.45939 1.3208 0.97993 1.2991 -0.015791 1.487 +-0.42254 -0.57928 -0.58529 -2.2375 0.51999 -0.79909 +0.32092 -0.13796 0.67098 0.24639 -0.36066 -0.032948 +-1.2408 -0.94836 0.026276 -0.37981 -0.02237 -0.38777 +0.20959 2.1466 -1.7027 -1.3169 -0.16515 -1.046 +-0.10482 1.3773 -1.2998 -0.014223 0.34065 -0.35362 +-0.66188 -1.2477 -0.62084 0.27682 0.1674 -0.8918 +-0.97246 -0.73017 1.3843 1.5549 0.1067 0.85754 +0.74567 -0.032694 1.1153 0.97318 -0.0033905 0.85059 +0.29324 -0.090608 -0.4945 -1.0484 -0.14987 -1.0141 +-0.86818 0.44948 1.8531 0.51896 -0.021141 1.8486 +0.362 -0.29749 -0.66525 0.21709 -0.15594 -1.4087 +-0.17675 0.36465 -0.45423 -1.262 0.22968 -1.246 +-0.34633 -0.16067 -1.2216 -1.3019 -0.040891 -1.2935 +0.44608 -0.57732 0.25606 -1.1664 0.54705 -0.19859 +0.45398 -0.55214 -0.33433 -0.085418 -0.10094 -0.48509 +0.12407 0.022419 -1.0312 -0.47727 0.20924 -1.2961 +-0.76644 -1.1794 1.2345 0.84756 0.1532 0.77648 +-0.10329 -0.53768 -0.67677 -0.58708 -0.014634 -0.036347 +0.2378 0.15372 0.49652 0.29193 0.19047 1.152 +0.024605 -0.38937 -0.89907 -0.42106 0.16921 -0.80893 +0.28812 0.26265 -0.94234 -0.88527 -0.49803 0.48254 +0.85086 0.11783 1.5014 1.2382 0.24441 1.3649 +0.86172 0.14894 -0.4846 -1.3488 -0.41844 -1.1372 +0.67971 -0.27488 -0.50687 -0.79153 -0.093399 -1.391 +-0.91977 -0.66099 0.5801 0.46587 -0.2263 1.43 +0.88213 -0.48674 -0.42406 -1.2762 0.28981 -1.0813 +-0.36583 0.51518 1.4491 1.4995 -0.073755 1.1218 +-0.54006 -0.59443 0.81263 0.65809 -0.15621 1.2508 +1.2125 -0.012648 -0.92657 -0.81972 -0.1536 -1.0176 +0.42493 0.34558 -1.7672 -1.3503 -0.045928 0.37449 +0.17097 -0.86593 -0.13424 1.0257 0.058014 0.91044 +-1.393 0.5338 1.8514 2.291 0.15305 0.30028 +-0.58552 -1.5337 1.5133 0.9976 0.64638 1.4428 +0.046272 -0.56387 -0.86063 -1.0462 0.014457 -1.3038 +0.34933 -0.16796 -0.27854 -0.27327 -0.0040928 -0.17912 +-1.0672 0.3979 1.208 0.50111 -0.013978 0.015097 +0.31052 -0.46723 -1.1237 0.59267 0.30978 -1.0169 +-0.55337 -0.42776 -0.12612 -0.41838 -0.56558 -0.58189 +0.3925 0.15644 -0.72963 -0.66601 -0.10837 -0.27787 +-0.48513 -1.4119 -0.16889 -0.19646 -0.068098 -0.084247 +0.16692 1.5447 -1.3064 -1.3338 -0.25668 -0.48832 +-0.36092 0.31518 -0.44815 -1.4019 -0.47505 -0.37187 +-1.8192 -0.57745 1.1304 0.262 -0.3595 0.58577 +-0.065383 0.07156 1.4931 2.3215 0.85149 1.4585 +-1.119 0.70896 1.0498 0.74334 0.75838 1.6107 +-0.17682 -0.21029 -0.74465 -0.83806 0.10827 -1.2829 +0.69834 -0.082402 0.64008 -0.83119 -0.26766 0.36961 +-0.28266 1.1929 -0.15174 0.098554 -0.33989 -0.6376 +1.5369 1.8434 0.0030761 -0.59703 0.14497 -1.5165 +0.35023 -0.28475 -0.93594 -1.0937 -0.46614 -2.188 +0.62308 1.0873 -0.0037182 0.86847 -0.48699 -0.10105 +-1.0408 -0.99866 2.0799 1.1634 0.092516 0.30401 +-0.87125 -0.88987 1.0278 1.0157 -0.23725 1.2377 +-0.020591 -0.03398 -0.024834 -1.3588 -0.045961 -0.89693 +0.9213 -0.57037 1.044 1.2994 0.046517 0.66563 +-0.87288 -0.96382 -0.704 -1.2184 0.046903 -0.30008 +0.77586 -0.34168 -0.09867 -0.37744 -0.24309 -0.13441 +0.19521 0.67595 1.4533 1.5115 0.19553 0.79596 +-1.3273 1.0891 1.2544 0.98928 0.045725 0.54963 +0.59176 0.65915 -0.84578 -0.080229 -0.26961 0.24045 +-0.66958 -1.042 -1.2138 -0.7612 -0.22775 -0.40062 +1.1154 -0.57069 -0.6592 -2.1961 -0.013175 0.46007 +-0.5254 0.0031225 -0.77758 0.8169 0.13224 -0.65572 +0.24551 1.5078 0.10719 1.1454 0.70578 0.59051 +0.29875 -0.11455 -1.0497 -0.77881 0.080708 -0.48337 +-0.1047 0.011628 1.2504 0.41776 -0.20102 1.2252 +0.44808 -0.8165 -0.080134 -0.49618 0.051011 -0.71722 +2.0365 1.5592 1.3257 1.2472 -0.47899 0.10943 +-0.16507 -0.66011 0.98739 0.58519 0.245 -0.43277 +-0.028366 -0.16961 -1.3266 0.14248 -0.24634 -1.1154 +0.92842 1.8842 1.3169 1.0358 -0.20988 0.88021 +0.33158 0.32463 -0.50924 0.40233 0.54391 -0.24309 +1.2555 0.1928 -0.487 0.048779 -0.23483 -1.477 +0.75021 0.85943 -0.2323 0.10748 -0.68906 0.84276 +0.6297 1.7397 -1.6136 -0.43268 -0.21442 -0.77462 +0.53168 1.0807 1.0853 0.62304 0.44036 0.48087 +-0.31256 -0.69771 -0.88556 -1.333 0.038614 -1.5744 +-0.039695 -0.52447 0.91401 -0.93272 0.53434 -0.080746 +-0.16596 0.56821 0.76008 0.45442 0.10286 0.6539 +-0.4331 -0.89669 -1.3097 -1.2157 0.1065 -0.8512 +-0.34708 -0.51457 -1.012 -0.39437 -0.55374 -1.144 +0.024082 0.7128 -1.3702 -1.4492 -0.10228 -0.59071 +-0.0037109 -0.68845 -0.649 -0.91581 0.066805 -0.98583 +0.68706 0.067424 0.87139 0.7938 -0.099645 1.529 +-0.31183 0.57814 -0.80815 -0.66724 -0.31919 -0.61319 +-0.11153 -0.6246 -0.27979 -0.18363 0.83639 0.014919 +0.20406 1.5838 -0.96334 -1.1228 -0.17808 -1.2123 +-0.1134 0.63358 -0.53321 -0.84276 -0.27657 -0.36992 +0.25517 0.67006 -0.1349 0.18275 0.40982 -0.62487 +-1.2684 0.31042 0.91155 0.66143 0.2483 -0.12434 +-0.97542 -0.85419 0.7663 0.16362 -0.18737 0.67266 +-0.043882 -0.62746 -0.82816 -0.40626 -0.051048 -0.61297 +0.59605 -0.45852 1.2962 0.78156 -0.48154 0.17778 +-0.06266 1.1144 -0.80524 -0.3189 -0.16038 -0.96372 +-1.1821 1.0798 -1.3407 -0.52643 0.12458 -0.7871 +0.59446 0.89186 -0.97856 -0.64658 0.2712 -1.5538 +0.15067 0.41827 -1.0487 -1.0551 0.19143 -1.4537 +-1.073 0.022587 -1.7088 -1.3777 0.1964 -0.84025 +0.20928 1.8026 1.2073 2.78 0.15131 0.3448 +-1.1317 -0.6359 -0.70457 -1.676 -0.22886 -0.58769 +-0.039428 -0.58746 0.56 0.7896 -0.052581 0.99511 +0.55023 -0.20403 0.138 -0.70518 0.66927 -0.28861 +0.57423 1.1886 0.092876 0.025677 -0.41099 -1.2858 +-0.14179 1.5827 -0.94328 0.7703 -0.43967 -0.50448 +0.14666 1.0492 -0.0030259 -0.62418 -0.087515 -0.048386 diff --git a/test/golden/six_traits_structure_input.txt b/test/golden/six_traits_structure_input.txt new file mode 100644 index 00000000..7f4768ca --- /dev/null +++ b/test/golden/six_traits_structure_input.txt @@ -0,0 +1,7 @@ +Trait1 Trait2 Trait3 Trait4 Trait5 Trait6 +0 0 0 0 0 0 +1 0 0 1 0 0 +0 0 0 1 0 0 +0 0 0 0 0 0 +0 0 0 0 0 0 +0 0 1 1 0 0 diff --git a/test/parity_check.py b/test/parity_check.py new file mode 100755 index 00000000..490caa12 --- /dev/null +++ b/test/parity_check.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python3 +"""Parity check: bin/bnw against the Bayesian Network Webserver itself. + +The golden files in test/golden/ were produced by the *web application* +(gn-machines' bnw container, 2026-11-12): the six continuous traits of BNW's own +8-node example were posted to bn_genenet.php and run through +execute_bn_gom.php, and the container's /var/lib/genenet/bnw/c6x* files copied +out. So this compares our headless driver against the reference +implementation, not against a memory of it. + +What is compared: + + * continuous_input.txt -- the file the C programs read. Ours is written from + the matrix with a type line of 1s (continuous); the golden one has the same + numbers in the same order. + * structure_input.txt -- the learned, thresholded adjacency. This must match + exactly: same variables in the same order, same 0/1 cells. + +Run: test/parity_check.py [--bin-dir DIR] + +The driver needs the four BNW binaries (var_lib_genenet_bnw/build.sh). Without +them the check says so and exits 77 (skip), so it can sit in a test suite that +runs where BNW is not installed. +""" + +import argparse +import subprocess +import sys +import tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent +REPO = HERE.parent +GOLDEN = HERE / "golden" + + +def fail(message): + print(f"FAIL: {message}") + return 1 + + +def main(argv): + parser = argparse.ArgumentParser() + parser.add_argument("--bin-dir", default=None, + help="where network_score/structure/get_kbest_* are") + args = parser.parse_args(argv) + + command = [str(REPO / "bin" / "bnw"), "learn", + "--input", str(GOLDEN / "six_traits_matrix.tsv"), + "--keep", "--workdir", tempfile.mkdtemp(prefix="bnw-parity-")] + if args.bin_dir: + command += ["--bin-dir", args.bin_dir] + completed = subprocess.run(command, capture_output=True, text=True) + if completed.returncode == 77: + print("SKIP: the BNW binaries are not installed") + return 77 + if completed.returncode != 0: + return fail(f"bnw learn failed ({completed.returncode}): {completed.stderr.strip()}") + + workdir = Path(completed.stderr.splitlines()[-1].split("kept: ")[-1]) + print(f"work directory: {workdir}") + + # 1. the input file the C programs read + ours = (workdir / "continuous_input.txt").read_text() + golden = (GOLDEN / "six_traits_continuous_input.txt").read_text() + ours_rows = [line for line in ours.splitlines() if line.strip()] + golden_rows = [line for line in golden.splitlines() if line.strip()] + if len(ours_rows) != len(golden_rows): + return fail(f"continuous_input.txt: {len(ours_rows)} lines, " + f"golden has {len(golden_rows)}") + if ours_rows[0] != golden_rows[0]: + return fail("continuous_input.txt: header differs\n" + f" ours: {ours_rows[0]!r}\n golden: {golden_rows[0]!r}") + if ours_rows[1] != golden_rows[1]: + return fail("continuous_input.txt: type line differs\n" + f" ours: {ours_rows[1]!r}\n golden: {golden_rows[1]!r}") + print("ok continuous_input.txt matches the web application's") + + # 2. the learned adjacency + ours = (workdir / "structure_input.txt").read_text() + golden = (GOLDEN / "six_traits_structure_input.txt").read_text() + + def cells(text): + rows = [line.rstrip("\r") for line in text.splitlines() if line.strip()] + names = [cell for cell in rows[0].split("\t") if cell] + matrix = [[cell for cell in row.split("\t") if cell] for row in rows[1:]] + return names, matrix + + ours_names, ours_matrix = cells(ours) + golden_names, golden_matrix = cells(golden) + if ours_names != golden_names: + return fail(f"structure_input.txt: variables differ\n" + f" ours: {ours_names}\n golden: {golden_names}") + if ours_matrix != golden_matrix: + print("FAIL: structure_input.txt: adjacency differs") + print(f" ours: {ours_matrix}") + print(f" golden: {golden_matrix}") + return 1 + edges = sum(cell == "1" for row in ours_matrix for cell in row) + print(f"ok structure_input.txt matches the web application's ({edges} edge(s))") + + # 3. the driver's own report agrees with the file + reported = [line.split("\t") for line in completed.stdout.splitlines() + if line and not line.startswith("#") and not line.startswith("from")] + reported_edges = {(row[0], row[1]) for row in reported if row[3] == "1"} + expected = {(ours_names[i], ours_names[j]) + for i, row in enumerate(ours_matrix) + for j, cell in enumerate(row) if cell == "1"} + if reported_edges != expected: + return fail(f"the stdout edge list disagrees with structure_input.txt: " + f"{sorted(reported_edges)} vs {sorted(expected)}") + print(f"ok stdout reports the same {len(reported_edges)} edge(s)") + + print("\nPARITY OK") + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) |
