From d04a3b894b2a1dfa0182e59bae3f81aa8c4de432 Mon Sep 17 00:00:00 2001 From: Shing Zhan Date: Sun, 14 Jan 2024 18:07:43 +0000 Subject: [PATCH] Rename variables --- python/tests/beagle_numba.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/tests/beagle_numba.py b/python/tests/beagle_numba.py index 92a263a487..8cc6d09fed 100644 --- a/python/tests/beagle_numba.py +++ b/python/tests/beagle_numba.py @@ -74,7 +74,7 @@ def convert_to_genetic_map_positions(pos, genetic_map=None): @njit -def get_weights(genotyped_pos, ungenotyped_pos, genotyped_cm, ungenotyped_cm): +def get_weights(typed_pos, untyped_pos, typed_cm, untyped_cm): """ Get weights for ungenotyped markers in the query haplotype, which are used in linear interpolation of HMM state probabilities at the ungenotyped markers. @@ -93,8 +93,8 @@ def get_weights(genotyped_pos, ungenotyped_pos, genotyped_cm, ungenotyped_cm): :rtype: tuple(numpy.ndarray, numpy.ndarray) """ MIN_CM_DIST = 1e-7 # Avoid division by zero. - m = len(genotyped_pos) - x = len(ungenotyped_pos) + m = len(typed_pos) + x = len(untyped_pos) # Calculate weights for ungenotyped markers. weights = np.zeros(x, dtype=np.float32) # Identify genotype markers m and m+1 bounding ungenotyped marker i. @@ -103,19 +103,19 @@ def get_weights(genotyped_pos, ungenotyped_pos, genotyped_cm, ungenotyped_cm): # TODO: Refactor using np.searchsorted(). idx_m = m - 1 for idx_x in range(x - 1, -1, -1): - while idx_m > 0 and ungenotyped_pos[idx_x] < genotyped_pos[idx_m]: + while idx_m > 0 and untyped_pos[idx_x] < typed_pos[idx_m]: idx_m = max(idx_m - 1, 0) if idx_m == m - 1: # Right of the last genotyped marker. weights[idx_x] = 0.0 - elif idx_m == 0 and ungenotyped_pos[idx_x] < genotyped_pos[idx_m]: + elif idx_m == 0 and untyped_pos[idx_x] < typed_pos[idx_m]: # Left of the first genotyped marker. weights[idx_x] = 1.0 else: # Between two genotyped markers. - cm_mP1_x = genotyped_cm[idx_m + 1] - ungenotyped_cm[idx_x] + cm_mP1_x = typed_cm[idx_m + 1] - untyped_cm[idx_x] # TODO: Check if this a subtle source of numerical error. - cm_mP1_m = max(genotyped_cm[idx_m + 1] - genotyped_cm[idx_m], MIN_CM_DIST) + cm_mP1_m = max(typed_cm[idx_m + 1] - typed_cm[idx_m], MIN_CM_DIST) weights[idx_x] = cm_mP1_x / cm_mP1_m left_idx[idx_x] = idx_m return (weights, left_idx)