Skip to content
Snippets Groups Projects
Commit f74fa347 authored by Martin Larralde's avatar Martin Larralde
Browse files

Implement `__getstate__` and `__setstate__` for `Hit` and `MinimizerInfo`

parent 2642ca11
No related branches found
Tags v0.4.0
No related merge requests found
import typing
from typing import Generic, List, Union, Iterable, TypeVar
from typing import Generic, List, Union, Iterable, Tuple, TypeVar
N = TypeVar("N")
Seq = Union[str, bytes, bytearray, memoryview]
......@@ -54,6 +54,8 @@ class Hit(Generic[N]):
def __init__(self, name: N, identity: float, matches: int, fragments: int): ...
def __repr__(self) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> Tuple[N, float, int, int]: ...
def __setstate__(self, state: Tuple[N, float, int, int]) -> None: ...
@property
def name(self) -> N: ...
@property
......@@ -68,6 +70,8 @@ class MinimizerInfo:
def __init__(self, hash: int, sequence_id: int, window_position: int): ...
def __repr__(self) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> Tuple[int, int, int]: ...
def __setstate__(self, state: Tuple[int, int, int]) -> None: ...
@property
def hash(self) -> int: ...
@property
......
......@@ -900,6 +900,12 @@ cdef class Hit:
and self.identity == other.identity
)
def __getstate__(self):
return self.name, self.matches, self.fragments, self.identity
def __setstate__(self, state):
self.name, self.matches, self.fragments, self.identity = state
cdef class MinimizerInfo:
"""The information about a single minimizer.
......@@ -936,6 +942,12 @@ cdef class MinimizerInfo:
and self.window_position == other.window_position
)
def __getstate__(self):
return self.hash, self.sequence_id, self.window_position
def __setstate__(self, state):
self.hash, self.sequence_id, self.window_position = state
# --- Methods ------------------------------------------------------------
@staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment