Skip to content

Commit 7d8f5f3

Browse files
tomwhitemergify[bot]
authored andcommitted
Remove duplicate dimension names to avoid Xarray UserWarning
1 parent a755269 commit 7d8f5f3

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

sgkit/tests/test_association.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def test_regenie_loco_regression(ndarray_type: str, covariate: bool) -> None:
340340
)
341341
)
342342
else:
343-
ds = ds.assign(sample_covariates=(("empty", "empty"), da.zeros((0, 0))))
343+
ds = ds.assign(sample_covariates=(("empty_1", "empty_2"), da.zeros((0, 0))))
344344

345345
ds = ds.assign(
346346
sample_traits=(("samples", "traits"), da.from_array(df_trait.to_numpy()))

sgkit/tests/test_pedigree.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def test_pedigree_kinship__Hamilton_Kerr_compress_parent_dimension(
522522
ds1["parent"] = dims, parent
523523
ds1["stat_Hamilton_Kerr_tau"] = dims, tau
524524
ds1["stat_Hamilton_Kerr_lambda"] = dims, lambda_
525-
ds1["founder_kinship"] = ["founders", "founders"], founder_kinship
525+
ds1["founder_kinship"] = ["founders_1", "founders_2"], founder_kinship
526526
ds1["founder_indices"] = ["founders"], founder_indices
527527
# test case with parents dim length > 2
528528
parent, tau, lambda_ = widen_parent_arrays(
@@ -532,9 +532,9 @@ def test_pedigree_kinship__Hamilton_Kerr_compress_parent_dimension(
532532
ds2["parent"] = dims, parent
533533
ds2["stat_Hamilton_Kerr_tau"] = dims, tau
534534
ds2["stat_Hamilton_Kerr_lambda"] = dims, lambda_
535-
ds2["founder_kinship"] = ["founders", "founders"], founder_kinship
535+
ds2["founder_kinship"] = ["founders_1", "founders_2"], founder_kinship
536536
ds2["founder_indices"] = ["founders"], founder_indices
537-
assert (ds1.dims["parents"], ds2.dims["parents"]) == (2, n_parent)
537+
assert (ds1.sizes["parents"], ds2.sizes["parents"]) == (2, n_parent)
538538
# collect method arguments
539539
kwargs = dict(method="Hamilton-Kerr", allow_half_founders=n_half_founder > 0)
540540
if use_founder_kinship:
@@ -619,7 +619,7 @@ def test_pedigree_kinship__raise_on_half_founder(method, initial_kinship, parent
619619
ds["stat_Hamilton_Kerr_tau"] = xr.ones_like(ds["parent_id"], dtype=np.uint8)
620620
ds["stat_Hamilton_Kerr_lambda"] = xr.zeros_like(ds["parent_id"], dtype=float)
621621
if initial_kinship:
622-
ds["founder_kinship"] = ["founders", "founders"], [[0.5, 0.0], [0.0, 0.5]]
622+
ds["founder_kinship"] = ["founders_1", "founders_2"], [[0.5, 0.0], [0.0, 0.5]]
623623
ds["founder_indices"] = ["founders"], [0, 1]
624624
kwargs = dict(
625625
founder_kinship="founder_kinship", founder_indices="founder_indices"
@@ -641,7 +641,7 @@ def test_pedigree_kinship__diploid_raise_on_parent_dimension(use_founder_kinship
641641
["S2", "S3", "."],
642642
]
643643
if use_founder_kinship:
644-
ds["founder_kinship"] = ["founders", "founders"], [[0.5, 0.0], [0.0, 0.5]]
644+
ds["founder_kinship"] = ["founders_1", "founders_2"], [[0.5, 0.0], [0.0, 0.5]]
645645
ds["founder_indices"] = ["founders"], [0, 1]
646646
kwargs = dict(
647647
founder_kinship="founder_kinship", founder_indices="founder_indices"
@@ -753,7 +753,7 @@ def test_pedigree_kinship__projection(
753753
known_founder_kinship = ds_full.stat_pedigree_kinship.values[
754754
unknown_founder_idx, :
755755
][:, unknown_founder_idx]
756-
ds_known["founder_kinship"] = ["founders", "founders"], known_founder_kinship
756+
ds_known["founder_kinship"] = ["founders_1", "founders_2"], known_founder_kinship
757757
with pytest.warns(DeprecationWarning):
758758
actual = sg.pedigree_kinship(
759759
ds_known,
@@ -867,7 +867,7 @@ def test_pedigree_kinship__raise_on_founder_variable_shape():
867867
["S1", "S2"],
868868
["S2", "S3"],
869869
]
870-
ds["founder_kinship"] = ["founders", "founders"], [[0.5, 0.1], [0.1, 0.5]]
870+
ds["founder_kinship"] = ["founders_1", "founders_2"], [[0.5, 0.1], [0.1, 0.5]]
871871
ds["founder_indices"] = ["founders2"], [0, 1, 2]
872872
with pytest.raises(
873873
ValueError,
@@ -887,7 +887,9 @@ def test_pedigree_kinship__raise_too_many_founders():
887887
["S1", "S2"],
888888
["S2", "S3"],
889889
]
890-
ds["founder_kinship"] = ["founders", "founders"], np.random.rand(36).reshape(6, 6)
890+
ds["founder_kinship"] = ["founders_1", "founders_2"], np.random.rand(36).reshape(
891+
6, 6
892+
)
891893
ds["founder_indices"] = ["founders"], np.arange(6)
892894
with pytest.raises(
893895
ValueError, match="The number of founders exceeds the total number of samples"
@@ -1035,7 +1037,7 @@ def test_pedigree_inbreeding__Hamilton_Kerr_compress_parent_dimension(
10351037
ds2["parent"] = dims, parent
10361038
ds2["stat_Hamilton_Kerr_tau"] = dims, tau
10371039
ds2["stat_Hamilton_Kerr_lambda"] = dims, lambda_
1038-
assert (ds1.dims["parents"], ds2.dims["parents"]) == (2, n_parent)
1040+
assert (ds1.sizes["parents"], ds2.sizes["parents"]) == (2, n_parent)
10391041
expect = pedigree_inbreeding(
10401042
ds1, method="Hamilton-Kerr", allow_half_founders=n_half_founder > 0
10411043
).stat_pedigree_inbreeding
@@ -1249,7 +1251,7 @@ def test_pedigree_inverse_kinship__Hamilton_Kerr_compress_parent_dimension(
12491251
ds2["parent"] = dims, parent
12501252
ds2["stat_Hamilton_Kerr_tau"] = dims, tau
12511253
ds2["stat_Hamilton_Kerr_lambda"] = dims, lambda_
1252-
assert (ds1.dims["parents"], ds2.dims["parents"]) == (2, n_parent)
1254+
assert (ds1.sizes["parents"], ds2.sizes["parents"]) == (2, n_parent)
12531255
expect = pedigree_inverse_kinship(
12541256
ds1, method="Hamilton-Kerr", allow_half_founders=n_half_founder > 0
12551257
).stat_pedigree_inverse_kinship

0 commit comments

Comments
 (0)