Skip to content

Commit

Permalink
add runtime_checkable to Slicer class to allow type checking slicers
Browse files Browse the repository at this point in the history
  • Loading branch information
biphasic committed Dec 30, 2022
1 parent 32664e9 commit b6b0c65
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tonic/slicers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from dataclasses import dataclass
from typing import Any, List, Tuple
from typing import Any, List, Tuple, runtime_checkable

import numpy as np
from typing_extensions import Protocol


@runtime_checkable
class Slicer(Protocol):
"""Base protocol class for slicers in Tonic.
Expand Down Expand Up @@ -101,7 +102,7 @@ def slice_with_metadata(
return [data[start:end] for start, end in metadata], targets


@dataclass
@dataclass(frozen=True)
class SliceByTimeBins:
"""
Slices data and targets along fixed number of bins of time length time_duration / bin_count * (1 + overlap).
Expand Down

0 comments on commit b6b0c65

Please sign in to comment.