@@ -570,6 +570,9 @@ def __eq__(self, other):
570570 and (self .end == other .end )
571571 )
572572
573+ def __repr__ (self ):
574+ return f"Region({ self ._contig !r} , { self ._start !r} , { self ._end !r} )"
575+
573576 def __str__ (self ):
574577 out = self ._contig
575578 if self ._start is not None or self ._end is not None :
@@ -927,7 +930,20 @@ def _jitter(a, fraction, random_state=np.random):
927930
928931
929932class CacheMiss (Exception ):
930- pass
933+ """Raised when a requested item is not present in the cache."""
934+
935+ def __init__ (self , key = None ):
936+ self .key = key
937+ if key is not None :
938+ message = f"Cache miss for key: { key !r} "
939+ else :
940+ message = "Cache miss: requested item not found in cache."
941+ super ().__init__ (message )
942+
943+ def __repr__ (self ):
944+ if self .key is not None :
945+ return f"CacheMiss({ self .key !r} )"
946+ return "CacheMiss()"
931947
932948
933949class LoggingHelper :
@@ -1531,12 +1547,10 @@ def _apply_allele_mapping(x, mapping, max_allele):
15311547
15321548def _dask_apply_allele_mapping (v , mapping , max_allele ):
15331549 if not isinstance (v , da .Array ):
1534- raise TypeError (
1535- f"Expected v to be a dask.array.Array, " f"got { type (v ).__name__ } "
1536- )
1550+ raise TypeError (f"Expected v to be a dask.array.Array, got { type (v ).__name__ } " )
15371551 if not isinstance (mapping , np .ndarray ):
15381552 raise TypeError (
1539- f"Expected mapping to be a numpy.ndarray, " f" got { type (mapping ).__name__ } "
1553+ f"Expected mapping to be a numpy.ndarray, got { type (mapping ).__name__ } "
15401554 )
15411555 assert v .ndim == 2
15421556 assert mapping .ndim == 2
@@ -1558,12 +1572,10 @@ def _genotype_array_map_alleles(gt, mapping):
15581572 # N.B., scikit-allel does not handle empty blocks well, so we
15591573 # include some extra logic to handle that better.
15601574 if not isinstance (gt , np .ndarray ):
1561- raise TypeError (
1562- f"Expected gt to be a numpy.ndarray, " f"got { type (gt ).__name__ } "
1563- )
1575+ raise TypeError (f"Expected gt to be a numpy.ndarray, got { type (gt ).__name__ } " )
15641576 if not isinstance (mapping , np .ndarray ):
15651577 raise TypeError (
1566- f"Expected mapping to be a numpy.ndarray, " f" got { type (mapping ).__name__ } "
1578+ f"Expected mapping to be a numpy.ndarray, got { type (mapping ).__name__ } "
15671579 )
15681580 assert gt .ndim == 3
15691581 assert mapping .ndim == 3
@@ -1585,11 +1597,11 @@ def _genotype_array_map_alleles(gt, mapping):
15851597def _dask_genotype_array_map_alleles (gt , mapping ):
15861598 if not isinstance (gt , da .Array ):
15871599 raise TypeError (
1588- f"Expected gt to be a dask.array.Array, " f" got { type (gt ).__name__ } "
1600+ f"Expected gt to be a dask.array.Array, got { type (gt ).__name__ } "
15891601 )
15901602 if not isinstance (mapping , np .ndarray ):
15911603 raise TypeError (
1592- f"Expected mapping to be a numpy.ndarray, " f" got { type (mapping ).__name__ } "
1604+ f"Expected mapping to be a numpy.ndarray, got { type (mapping ).__name__ } "
15931605 )
15941606 assert gt .ndim == 3
15951607 assert mapping .ndim == 2
0 commit comments