Commit 3f4c0ed
committed
Add/refine tests, draft docstring
Clean up dimension handling around summary functions and normalisation.
There is a slight speed advantage (according to a microbenchmark) and a
huge readability advantage to simply returning [value]. I keep all
computations specifying `keepdims`, but remove list indexing (i.e.
`AB[[0]]`) in favor of returning a list with a single scalar. It turns
out that vectorised numpy functions are actually slower in some cases
because the data we're operating on is so small. Finally, fix the
default normalisation function so that it works both on one-way and
two-way statistics. Users will still need to specify `hap_norm` when
appropriate (and a special case of `hap_norm` for two-way stats).
Per Peter's comment, I investigated dimension dropping and indeed,
general stats don't drop dimensions so I removed the dimension dropping
code. However, we return a matrix of `(m, m, k)` and we want
`(k, m, m)`, so `np.moveaxis` is still needed.
Added tests:
* Multiallelic multi sample-set. This tests operations on two sample
sets for multiallelic data (which excercises the norm function with
multiple sample sets). This test highlighted the slight changes needed
to the default normalisation function.
* Multi outputs. This test mimics a two-way stat called
on multiple indexes. It shows and tests the ability to compute
multiple statistics from the same haplotype counts matrix (which is
especially useful with the explosion of possible summary functions in
three-way, four-way stats).
In our biallelic test case, I also assert that the normalisation
function is never called and add a note about polarisation.
Finally, I add a draft docstring, but to complete this I think that the
two-locus docs are required. Also, I'd like to add some general
documentation.1 parent 4c04ff3 commit 3f4c0ed
2 files changed
Lines changed: 170 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2400 | 2400 | | |
2401 | 2401 | | |
2402 | 2402 | | |
2403 | | - | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
2404 | 2407 | | |
2405 | | - | |
| 2408 | + | |
2406 | 2409 | | |
2407 | | - | |
2408 | | - | |
2409 | | - | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
2410 | 2413 | | |
2411 | | - | |
2412 | | - | |
| 2414 | + | |
| 2415 | + | |
2413 | 2416 | | |
2414 | 2417 | | |
2415 | 2418 | | |
| |||
2480 | 2483 | | |
2481 | 2484 | | |
2482 | 2485 | | |
2483 | | - | |
| 2486 | + | |
2484 | 2487 | | |
2485 | 2488 | | |
2486 | 2489 | | |
2487 | | - | |
| 2490 | + | |
2488 | 2491 | | |
2489 | 2492 | | |
2490 | 2493 | | |
2491 | 2494 | | |
2492 | 2495 | | |
2493 | | - | |
| 2496 | + | |
2494 | 2497 | | |
2495 | 2498 | | |
2496 | 2499 | | |
2497 | | - | |
| 2500 | + | |
2498 | 2501 | | |
2499 | 2502 | | |
2500 | 2503 | | |
2501 | 2504 | | |
2502 | 2505 | | |
2503 | | - | |
| 2506 | + | |
2504 | 2507 | | |
2505 | 2508 | | |
2506 | 2509 | | |
2507 | | - | |
| 2510 | + | |
2508 | 2511 | | |
| 2512 | + | |
2509 | 2513 | | |
2510 | 2514 | | |
2511 | 2515 | | |
2512 | 2516 | | |
2513 | 2517 | | |
| 2518 | + | |
2514 | 2519 | | |
2515 | 2520 | | |
2516 | 2521 | | |
| |||
2525 | 2530 | | |
2526 | 2531 | | |
2527 | 2532 | | |
2528 | | - | |
| 2533 | + | |
2529 | 2534 | | |
2530 | 2535 | | |
2531 | | - | |
2532 | | - | |
2533 | | - | |
2534 | | - | |
2535 | | - | |
2536 | | - | |
2537 | | - | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
2538 | 2562 | | |
| 2563 | + | |
2539 | 2564 | | |
2540 | 2565 | | |
2541 | 2566 | | |
| |||
2573 | 2598 | | |
2574 | 2599 | | |
2575 | 2600 | | |
2576 | | - | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
2577 | 2612 | | |
2578 | 2613 | | |
2579 | 2614 | | |
| |||
2584 | 2619 | | |
2585 | 2620 | | |
2586 | 2621 | | |
2587 | | - | |
| 2622 | + | |
2588 | 2623 | | |
2589 | 2624 | | |
2590 | 2625 | | |
| |||
2599 | 2634 | | |
2600 | 2635 | | |
2601 | 2636 | | |
2602 | | - | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
2603 | 2655 | | |
2604 | 2656 | | |
2605 | 2657 | | |
| |||
2616 | 2668 | | |
2617 | 2669 | | |
2618 | 2670 | | |
2619 | | - | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10942 | 10942 | | |
10943 | 10943 | | |
10944 | 10944 | | |
| 10945 | + | |
| 10946 | + | |
| 10947 | + | |
| 10948 | + | |
| 10949 | + | |
| 10950 | + | |
| 10951 | + | |
| 10952 | + | |
| 10953 | + | |
| 10954 | + | |
| 10955 | + | |
| 10956 | + | |
| 10957 | + | |
| 10958 | + | |
| 10959 | + | |
| 10960 | + | |
| 10961 | + | |
| 10962 | + | |
| 10963 | + | |
| 10964 | + | |
| 10965 | + | |
| 10966 | + | |
| 10967 | + | |
| 10968 | + | |
| 10969 | + | |
| 10970 | + | |
| 10971 | + | |
| 10972 | + | |
| 10973 | + | |
| 10974 | + | |
| 10975 | + | |
| 10976 | + | |
| 10977 | + | |
| 10978 | + | |
| 10979 | + | |
| 10980 | + | |
| 10981 | + | |
| 10982 | + | |
| 10983 | + | |
| 10984 | + | |
| 10985 | + | |
| 10986 | + | |
| 10987 | + | |
| 10988 | + | |
| 10989 | + | |
| 10990 | + | |
| 10991 | + | |
| 10992 | + | |
| 10993 | + | |
| 10994 | + | |
| 10995 | + | |
| 10996 | + | |
| 10997 | + | |
| 10998 | + | |
| 10999 | + | |
| 11000 | + | |
| 11001 | + | |
| 11002 | + | |
| 11003 | + | |
| 11004 | + | |
| 11005 | + | |
| 11006 | + | |
| 11007 | + | |
| 11008 | + | |
| 11009 | + | |
| 11010 | + | |
| 11011 | + | |
| 11012 | + | |
| 11013 | + | |
10945 | 11014 | | |
10946 | 11015 | | |
10947 | 11016 | | |
10948 | 11017 | | |
10949 | 11018 | | |
10950 | 11019 | | |
10951 | 11020 | | |
10952 | | - | |
| 11021 | + | |
| 11022 | + | |
10953 | 11023 | | |
10954 | 11024 | | |
10955 | 11025 | | |
| |||
10958 | 11028 | | |
10959 | 11029 | | |
10960 | 11030 | | |
10961 | | - | |
10962 | | - | |
10963 | 11031 | | |
10964 | 11032 | | |
10965 | | - | |
| 11033 | + | |
10966 | 11034 | | |
10967 | 11035 | | |
10968 | 11036 | | |
| |||
0 commit comments