Skip to content

Commit

Permalink
fix: MyType doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Nov 6, 2021
1 parent 4bd99e8 commit 71ab9ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions atypes/typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# NT = partial(new_type, assign_to_globals=True)

FiltFunc = MyType(
"FiltFunc", Callable[[Any], bool],
doc="boolean function usually used to filter iterables",
aka={'filt', 'filt_func'}
'FiltFunc',
Callable[[Any], bool],
doc='boolean function usually used to filter iterables',
aka={'filt', 'filt_func'},
)
# TODO: how do we express the fixed size-ness?
FixedSizeSeq = MyType('FixedSizeSeq', Sequence)
Expand All @@ -27,7 +28,7 @@
Key = MyType('Key', Any, doc='Any object used to reference another', aka={'key', 'k'})

# Waveform = Iterable[Union[float, int]]
Sample = MyType('Sample', Number, doc='The numerical value of a digital signal sample', )
Sample = MyType('Sample', Number, doc='The numerical value of a digital signal sample',)

# TODO: How do we use the waveform? Several modes. Sometimes only iterable is needed.
# Sometimes iterable and sliceable. Sometimes length. But never reversable. So Sequence too strong.
Expand Down Expand Up @@ -56,7 +57,7 @@
'Feature',
Number,
doc='A number that represents a characteristic of something. '
'Usually appears as an item of an FV (a sequence of Features)',
'Usually appears as an item of an FV (a sequence of Features)',
)
# FV = FixedSizeSeq[Feature]

Expand All @@ -70,7 +71,7 @@
'Featurizer',
Callable[[Any], FV],
doc='A function that makes FVs (out of Chunks, other FVs, or anything really. '
'(This is a declaration that the output will be FVs, not what the input should be.)',
'(This is a declaration that the output will be FVs, not what the input should be.)',
)
ChkFeaturizer = MyType(
'ChkFeaturizer',
Expand All @@ -84,8 +85,8 @@
Sequence[Sample],
aka='segment',
doc='Data regarding an interval of time. This is often just a piece of waveform, '
'but could also be a bundle of several waveforms and other signals/datas that '
'happened in that interval of time.',
'but could also be a bundle of several waveforms and other signals/datas that '
'happened in that interval of time.',
)
Segments = MyType(
'Segments', Iterable[Segment], aka='segments', doc='An iterable of segments',
Expand All @@ -95,19 +96,19 @@
'TimeIndex',
Number,
doc='A number indexing time. Could be in an actual time unit, or could just be '
'an enumerator (i.e. "ordinal time")',
'an enumerator (i.e. "ordinal time")',
)
BT = MyType(
'BT',
TimeIndex,
doc='TimeIndex for the lower bound of an interval of time. '
'Stands for "Bottom Time". By convention, a BT is inclusive.',
'Stands for "Bottom Time". By convention, a BT is inclusive.',
)
TT = MyType(
'TT',
TimeIndex,
doc='TimeIndex for the upper bound of an interval of time. '
'Stands for "Upper Time". By convention, a TT is exclusive.',
'Stands for "Upper Time". By convention, a TT is exclusive.',
)
IntervalTuple = MyType(
'IntervalTuple',
Expand Down Expand Up @@ -136,7 +137,7 @@
'Hunk',
Slab, # extra condition over Slab: Fixed size interval
doc='A slab of items for an interval coming from a fixed-size segmentation of time. '
'(A slab: A collection of (time-indexed) items of a same interval of time.)',
'(A slab: A collection of (time-indexed) items of a same interval of time.)',
)

WaveformBytes = MyType('WaveformBytes', bytes)
Expand All @@ -151,7 +152,7 @@
int,
aka=['snip'],
doc='The smallest element of a signal language. '
'Technically, an index representing a region of a feature space partition.',
'Technically, an index representing a region of a feature space partition.',
)
Snips = MyType(
'Snips',
Expand All @@ -172,7 +173,7 @@
Callable[[Waveform], Snips],
aka=['snipper'],
doc='The function that gets you from a stream of samples (Waveform) to '
'a stream of snips (Snips)',
'a stream of snips (Snips)',
)

# --------------- STORES ---------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion atypes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def MyType(
name: str,
tp,
tp: type = Any,
doc: Optional[str] = None,
aka: Optional[Union[str, Iterable[str]]] = None,
*,
Expand Down

0 comments on commit 71ab9ca

Please sign in to comment.