From ca164201fd44abb8a6ba075252e615bd8ef47a0e Mon Sep 17 00:00:00 2001 From: nyanpasu64 Date: Sun, 3 May 2020 17:18:30 -0700 Subject: [PATCH] Fix type hints for stereo downmixing --- corrscope/channel.py | 6 +++--- corrscope/corrscope.py | 7 +++---- corrscope/wave.py | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/corrscope/channel.py b/corrscope/channel.py index 2918693..ed03fc9 100644 --- a/corrscope/channel.py +++ b/corrscope/channel.py @@ -15,7 +15,7 @@ from corrscope.config import ( ) from corrscope.triggers import MainTriggerConfig from corrscope.util import coalesce -from corrscope.wave import Wave, Flatten +from corrscope.wave import Wave, FlattenOrStr if TYPE_CHECKING: from corrscope.corrscope import Config @@ -37,8 +37,8 @@ class ChannelConfig(DumpableAttrs): amplification: Optional[float] = None # Stereo config - trigger_stereo: Optional[Flatten] = None - render_stereo: Optional[Flatten] = None + trigger_stereo: Optional[FlattenOrStr] = None + render_stereo: Optional[FlattenOrStr] = None line_color: Optional[str] = None diff --git a/corrscope/corrscope.py b/corrscope/corrscope.py index 7d08235..580eb3d 100644 --- a/corrscope/corrscope.py +++ b/corrscope/corrscope.py @@ -16,8 +16,7 @@ from corrscope.outputs import FFmpegOutputConfig, IOutputConfig from corrscope.renderer import Renderer, RendererConfig, RendererFrontend from corrscope.triggers import CorrelationTriggerConfig, PerFrameCache, SpectrumConfig from corrscope.util import pushd, coalesce -from corrscope.wave import Wave, Flatten - +from corrscope.wave import Wave, Flatten, FlattenOrStr PRINT_TIMESTAMP = True @@ -78,8 +77,8 @@ class Config( amplification: float # Stereo config - trigger_stereo: Flatten = Flatten.SumAvg - render_stereo: Flatten = Flatten.SumAvg + trigger_stereo: FlattenOrStr = Flatten.SumAvg + render_stereo: FlattenOrStr = Flatten.SumAvg trigger: CorrelationTriggerConfig # Can be overriden per Wave diff --git a/corrscope/wave.py b/corrscope/wave.py index 3e2d0f9..1c1a30d 100644 --- a/corrscope/wave.py +++ b/corrscope/wave.py @@ -143,7 +143,7 @@ class Wave: self, wave_path: str, amplification: float = 1.0, - flatten: Flatten = Flatten.SumAvg, + flatten: FlattenOrStr = Flatten.SumAvg, ): self.wave_path = wave_path self.amplification = amplification @@ -191,7 +191,7 @@ class Wave: else: raise CorrError(f"unexpected wavfile dtype {dtype}") - def with_flatten(self, flatten: Flatten, return_channels: bool) -> "Wave": + def with_flatten(self, flatten: FlattenOrStr, return_channels: bool) -> "Wave": new = copy.copy(self) new.flatten = flatten new.return_channels = return_channels