Skip to content

Commit ce09b35

Browse files
committed
Rename TreePosition to TreeIndexes
1 parent c23aafc commit ce09b35

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

python/tests/test_coalrate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _nonmissing_window_span(ts, windows):
6868
missing = 0.0
6969
num_edges = 0
7070
w = 0
71-
position = tsutil.TreePosition(ts)
71+
position = tsutil.TreeIndexes(ts)
7272
while position.interval.right < sequence_length:
7373
position.next()
7474
left, right = position.interval.left, position.interval.right
@@ -272,7 +272,7 @@ def _pair_coalescence_stat(
272272
sample_counts = nodes_sample.copy()
273273

274274
w = 0
275-
position = tsutil.TreePosition(ts)
275+
position = tsutil.TreeIndexes(ts)
276276
while position.interval.right < sequence_length:
277277
position.next()
278278
left, right = position.interval.left, position.interval.right

python/tests/test_extend_haplotypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def merge_paths(self, c, left, right):
414414
self.add_or_extend_edge(p_out, child, left, right)
415415

416416
def extend_haplotypes(self):
417-
tree_pos = tsutil.TreePosition(self.ts)
417+
tree_pos = tsutil.TreeIndexes(self.ts)
418418
if self.direction == 1:
419419
valid = tree_pos.next()
420420
else:

python/tests/test_haplotype_matching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def __init__(
113113
self.N = np.zeros(ts.num_nodes, dtype=int)
114114
# Efficiently compute the allelic state at a site
115115
self.allelic_state = np.zeros(ts.num_nodes, dtype=int) - 1
116-
# TreePosition so we can can update T and T_index between trees.
117-
self.tree_pos = tsutil.TreePosition(ts)
116+
# TreeIndexes so we can can update T and T_index between trees.
117+
self.tree_pos = tsutil.TreeIndexes(ts)
118118
self.parent = np.zeros(self.ts.num_nodes, dtype=int) - 1
119119
self.tree = tskit.Tree(self.ts)
120120
self.output = None

python/tests/test_ld_matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ class TreeState:
17691769
enables easy copying of the state for computing a matrix.
17701770
"""
17711771

1772-
pos: tsutil.TreePosition # current position in the tree sequence
1772+
pos: tsutil.TreeIndexes # current position in the tree sequence
17731773
parent: np.ndarray # parent node of a given node (connected by an edge)
17741774
branch_len: np.ndarray # length of the branch above a particular child node
17751775
node_samples: BitSet # samples that exist under a given node, this is a
@@ -1784,7 +1784,7 @@ class TreeState:
17841784
edges_in: List[int] # list of edges added during iteration
17851785

17861786
def __init__(self, ts, sample_sets, num_sample_sets, sample_index_map):
1787-
self.pos = tsutil.TreePosition(ts)
1787+
self.pos = tsutil.TreeIndexes(ts)
17881788
self.parent = -np.ones(ts.num_nodes, dtype=np.int64)
17891789
self.branch_len = np.zeros(ts.num_nodes, dtype=np.float64)
17901790
self.node_samples = BitSet(ts.num_samples, ts.num_nodes * num_sample_sets)

python/tests/test_relatedness_vector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def relatedness_vector(ts, sample_weights, windows=None, nodes=None, **kwargs):
297297
if drop_dimension:
298298
windows = [0, ts.sequence_length]
299299

300-
tree_pos = tsutil.TreePosition(ts)
300+
tree_pos = tsutil.TreeIndexes(ts)
301301
breakpoints = np.fromiter(ts.breakpoints(), dtype="float")
302302
index = np.searchsorted(breakpoints, windows[0])
303303
if breakpoints[index] > windows[0]:

python/tests/test_tree_positioning.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class StatefulTree:
4444

4545
def __init__(self, ts):
4646
self.ts = ts
47-
self.tree_pos = tsutil.TreePosition(ts)
47+
self.tree_pos = tsutil.TreeIndexes(ts)
4848
self.parent = [-1 for _ in range(ts.num_nodes)]
4949

5050
def __str__(self):
@@ -158,7 +158,7 @@ def iter_backward(self, index):
158158
def check_iters_forward(ts):
159159
alg_t_output = tsutil.algorithm_T(ts)
160160
lib_tree = tskit.Tree(ts)
161-
tree_pos = tsutil.TreePosition(ts)
161+
tree_pos = tsutil.TreeIndexes(ts)
162162
sample_count = np.zeros(ts.num_nodes, dtype=int)
163163
sample_count[ts.samples()] = 1
164164
parent1 = [-1 for _ in range(ts.num_nodes)]
@@ -208,7 +208,7 @@ def check_iters_back(ts):
208208
i = len(alg_t_output) - 1
209209

210210
lib_tree = tskit.Tree(ts)
211-
tree_pos = tsutil.TreePosition(ts)
211+
tree_pos = tsutil.TreeIndexes(ts)
212212
parent1 = [-1 for _ in range(ts.num_nodes)]
213213

214214
lib_tree.last()
@@ -422,35 +422,35 @@ def test_seek_backward_out_range_is_empty(self, index):
422422
check_seek_backward_out_range_is_empty(ts, index)
423423

424424

425-
class TestTreePositionStep:
425+
class TestTreeIndexesStep:
426426
def ts(self):
427427
return tsutil.all_trees_ts(3)
428428

429429
@pytest.mark.parametrize("index", [0, 1, 2])
430430
def test_tree_position_step_forward(self, index):
431431
ts = self.ts()
432-
tree1_pos = tsutil.TreePosition(ts)
432+
tree1_pos = tsutil.TreeIndexes(ts)
433433
tree1_pos.seek_forward(index)
434434
tree1_pos.step(direction=1)
435-
tree2_pos = tsutil.TreePosition(ts)
435+
tree2_pos = tsutil.TreeIndexes(ts)
436436
tree2_pos.seek_forward(index + 1)
437437
tree1_pos.assert_equal(tree2_pos)
438438

439439
@pytest.mark.parametrize("index", [1, 2, 3])
440440
def test_tree_position_step_backward(self, index):
441441
ts = self.ts()
442-
tree1_pos = tsutil.TreePosition(ts)
442+
tree1_pos = tsutil.TreeIndexes(ts)
443443
tree1_pos.seek_backward(index)
444444
tree1_pos.step(direction=-1)
445-
tree2_pos = tsutil.TreePosition(ts)
445+
tree2_pos = tsutil.TreeIndexes(ts)
446446
tree2_pos.seek_backward(index - 1)
447447
tree1_pos.assert_equal(tree2_pos)
448448

449449
def test_tree_position_step_invalid_direction(self):
450450
ts = self.ts()
451451
# Test for unallowed direction
452452
with pytest.raises(ValueError, match="Direction must be FORWARD"):
453-
tsutil.TreePosition(ts).step(direction="foo")
453+
tsutil.TreeIndexes(ts).step(direction="foo")
454454

455455

456456
class TestSeeking:

python/tests/tsutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ class EdgeRange:
17371737
order: typing.List
17381738

17391739

1740-
class TreePosition:
1740+
class TreeIndexes:
17411741
def __init__(self, ts):
17421742
self.ts = ts
17431743
self.index = -1

0 commit comments

Comments
 (0)