Skip to content

Commit

Permalink
Update the class definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromekelleher committed Jul 26, 2024
1 parent a75d933 commit 771d989
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions algorithms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Python version of the simulation algorithm.
"""
from __future__ import annotations

import argparse
import dataclasses
import heapq
Expand Down Expand Up @@ -111,23 +113,25 @@ def find(self, v):
return j + 1


# Once we drop support for 3.9 we can use slots=True to prevent
# writing extra attrs.
@dataclasses.dataclass # (slots=True)
class Segment:
"""
A class representing a single segment. Each segment has a left
and right, denoting the loci over which it spans, a node and a
next, giving the next in the chain.
"""

def __init__(self, index):
self.left = None
self.right = None
self.node = None
self.prev = None
self.next = None
self.index = index
self.population = None
self.label = 0
self.lineage = None
index: int
left: float = 0
right: float = 0
node: int = -1
prev: Segment = None
next: Segment = None # noqa: A003
lineage: Lineage = None
population: int = -1
label: int = 0

def __repr__(self):
return repr((self.left, self.right, self.node))
Expand Down Expand Up @@ -1070,7 +1074,6 @@ def alloc_segment(
prev=None,
next=None, # noqa: A002
label=0,
hull=None,
):
"""
Pops a new segment off the stack and sets its properties.
Expand All @@ -1083,7 +1086,6 @@ def alloc_segment(
s.next = next
s.prev = prev
s.label = label
s.hull = hull
return s

def alloc_lineage(self, head):
Expand Down

0 comments on commit 771d989

Please sign in to comment.