@@ -560,6 +560,29 @@ def test_pedigree_kinship__Hamilton_Kerr_compress_parent_dimension(
560560 np .testing .assert_array_almost_equal (actual , expect )
561561
562562
563+ def test_pedigree_kinship__Hamilton_Kerr_chunked_mem ():
564+ # tests fix for https://github.com/sgkit-dev/sgkit/issues/1333
565+ # if chunking is not applied to the ploidy matrix correctly
566+ # this will try to allocate > 7TB of RAM (and presumably fail)
567+ ds = xr .Dataset ()
568+ ds ["parent" ] = ["samples" , "parents" ], np .full ((1_000_000 , 2 ), - 1 , int )
569+ ds ["stat_Hamilton_Kerr_tau" ] = ["samples" , "parents" ], np .full (
570+ (1_000_000 , 2 ), 2 , np .uint64
571+ )
572+ ds ["stat_Hamilton_Kerr_lambda" ] = ["samples" , "parents" ], np .full (
573+ (1_000_000 , 2 ), 0.0
574+ )
575+ matrix = sg .pedigree_kinship (
576+ ds ,
577+ method = "Hamilton-Kerr" ,
578+ chunks = ((10 , 999990 ), (20 , 999980 )),
579+ return_relationship = True ,
580+ ).stat_pedigree_relationship
581+ expect = np .eye (10 , 20 )
582+ actual = matrix [0 :10 , 0 :20 ].compute ()
583+ np .testing .assert_array_almost_equal (actual , expect )
584+
585+
563586@pytest .mark .parametrize ("method" , ["diploid" , "Hamilton-Kerr" ])
564587def test_pedigree_kinship__half_founder (method ):
565588 ds0 = sg .simulate_genotype_call_dataset (n_variant = 1 , n_sample = 6 )
0 commit comments