@@ -1580,21 +1580,25 @@ def _apply_allele_mapping(x, mapping, max_allele):
15801580
15811581def _dask_apply_allele_mapping (v , mapping , max_allele ):
15821582 if not isinstance (v , da .Array ):
1583- raise TypeError (f"Expected v to be a dask.array.Array, got { type (v ).__name__ } " )
1583+ raise TypeError (
1584+ f"Expected input array to be a dask.array.Array, got { type (v ).__name__ } "
1585+ )
15841586 if not isinstance (mapping , np .ndarray ):
15851587 raise TypeError (
15861588 f"Expected mapping to be a numpy.ndarray, got { type (mapping ).__name__ } "
15871589 )
15881590 if v .ndim != 2 :
1589- raise ValueError (f"Expected v to be 2-dimensional, got { v .ndim } dimensions" )
1591+ raise ValueError (
1592+ f"Expected input array to be 2-dimensional, got { v .ndim } dimensions"
1593+ )
15901594 if mapping .ndim != 2 :
15911595 raise ValueError (
15921596 f"Expected mapping to be 2-dimensional, got { mapping .ndim } dimensions"
15931597 )
15941598 if v .shape [0 ] != mapping .shape [0 ]:
15951599 raise ValueError (
1596- f"v and mapping must have same first dimension, "
1597- f"got v.shape[0]= { v .shape [0 ]} and mapping.shape[0]= { mapping .shape [0 ]} "
1600+ "Expected input array and mapping to have the same first dimension, "
1601+ f"got { v .shape [0 ]} and { mapping .shape [0 ]} "
15981602 )
15991603 v = v .rechunk ((v .chunks [0 ], - 1 ))
16001604 mapping = da .from_array (mapping , chunks = (v .chunks [0 ], - 1 ))
@@ -1619,33 +1623,39 @@ def _genotype_array_map_alleles(gt, mapping):
16191623 f"Expected mapping to be a numpy.ndarray, got { type (mapping ).__name__ } "
16201624 )
16211625 if gt .ndim != 3 :
1622- raise ValueError (f"Expected gt to be 3-dimensional, got { gt .ndim } dimensions" )
1626+ raise ValueError (
1627+ f"Expected genotype calls array to be 3-dimensional, got { gt .ndim } dimensions"
1628+ )
16231629 if mapping .ndim != 3 :
16241630 raise ValueError (
16251631 f"Expected mapping to be 3-dimensional, got { mapping .ndim } dimensions"
16261632 )
16271633 if gt .shape [0 ] != mapping .shape [0 ]:
16281634 raise ValueError (
1629- f"gt and mapping must have same first dimension, "
1630- f"got gt.shape[0]= { gt .shape [0 ]} and mapping.shape[0]= { mapping .shape [0 ]} "
1635+ "Expected genotype calls array and mapping to have the same first dimension, "
1636+ f"got { gt .shape [0 ]} and { mapping .shape [0 ]} "
16311637 )
16321638 if gt .shape [1 ] <= 0 :
1633- raise ValueError (f"Expected gt.shape[1] > 0, got { gt .shape [1 ]} " )
1639+ raise ValueError (f"Expected genotype calls axis 1 to be > 0, got { gt .shape [1 ]} " )
16341640 if gt .shape [2 ] != 2 :
1635- raise ValueError (f"Expected gt.shape[2] == 2 (diploid), got { gt .shape [2 ]} " )
1641+ raise ValueError (
1642+ f"Expected genotype calls axis 2 to be 2 (diploid), got { gt .shape [2 ]} "
1643+ )
16361644 if gt .size > 0 :
16371645 # Block is not empty, can pass through to GenotypeArray.
16381646 if gt .shape [0 ] <= 0 :
16391647 raise RuntimeError (
1640- f"Internal error: gt.size > 0 but gt.shape[0] = { gt .shape [0 ]} "
1648+ f"Internal error: non-empty genotype block but axis 0 is { gt .shape [0 ]} . "
1649+ "Please open a GitHub issue."
16411650 )
16421651 m = mapping [:, 0 , :]
16431652 out = allel .GenotypeArray (gt ).map_alleles (m ).values
16441653 else :
16451654 # Block is empty so no alleles need to be mapped.
16461655 if gt .shape [0 ] != 0 :
16471656 raise RuntimeError (
1648- f"Internal error: gt.size == 0 but gt.shape[0] = { gt .shape [0 ]} "
1657+ f"Internal error: empty genotype block but axis 0 is { gt .shape [0 ]} . "
1658+ "Please open a GitHub issue."
16491659 )
16501660 out = gt
16511661 return out
0 commit comments