kopia lustrzana https://github.com/corrscope/corrscope
Move MatplotlibRenderer.create_window parameter into cfg
rodzic
06159555a1
commit
4a25b41d22
|
@ -33,7 +33,6 @@ class Config:
|
||||||
render: RendererConfig
|
render: RendererConfig
|
||||||
|
|
||||||
outputs: List[outputs.IOutputConfig]
|
outputs: List[outputs.IOutputConfig]
|
||||||
create_window: bool = False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def render_width_s(self) -> float:
|
def render_width_s(self) -> float:
|
||||||
|
@ -97,12 +96,11 @@ class Ovgen:
|
||||||
# Calculate number of frames (TODO master file?)
|
# Calculate number of frames (TODO master file?)
|
||||||
render_width_s = self.cfg.render_width_s
|
render_width_s = self.cfg.render_width_s
|
||||||
fps = self.cfg.fps
|
fps = self.cfg.fps
|
||||||
create_window = self.cfg.create_window
|
|
||||||
|
|
||||||
nframes = fps * self.waves[0].get_s()
|
nframes = fps * self.waves[0].get_s()
|
||||||
nframes = int(nframes) + 1
|
nframes = int(nframes) + 1
|
||||||
|
|
||||||
renderer = MatplotlibRenderer(self.cfg.render, self.nchan, create_window)
|
renderer = MatplotlibRenderer(self.cfg.render, self.nchan)
|
||||||
|
|
||||||
if RENDER_PROFILING:
|
if RENDER_PROFILING:
|
||||||
begin = time.perf_counter()
|
begin = time.perf_counter()
|
||||||
|
|
|
@ -24,6 +24,7 @@ class RendererConfig:
|
||||||
|
|
||||||
nrows: Optional[int] = None
|
nrows: Optional[int] = None
|
||||||
ncols: Optional[int] = None
|
ncols: Optional[int] = None
|
||||||
|
create_window: bool = False
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if not self.nrows:
|
if not self.nrows:
|
||||||
|
@ -61,10 +62,9 @@ class MatplotlibRenderer:
|
||||||
|
|
||||||
DPI = 96
|
DPI = 96
|
||||||
|
|
||||||
def __init__(self, cfg: RendererConfig, nplots: int, create_window: bool):
|
def __init__(self, cfg: RendererConfig, nplots: int):
|
||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
self.nplots = nplots
|
self.nplots = nplots
|
||||||
self.create_window = create_window
|
|
||||||
|
|
||||||
# Setup layout
|
# Setup layout
|
||||||
# "ncols=1" is good for vertical layouts.
|
# "ncols=1" is good for vertical layouts.
|
||||||
|
@ -121,7 +121,7 @@ class MatplotlibRenderer:
|
||||||
self.cfg.width / self.DPI,
|
self.cfg.width / self.DPI,
|
||||||
self.cfg.height / self.DPI
|
self.cfg.height / self.DPI
|
||||||
)
|
)
|
||||||
if self.create_window:
|
if self.cfg.create_window:
|
||||||
plt.show(block=False)
|
plt.show(block=False)
|
||||||
|
|
||||||
def _calc_layout(self) -> Tuple[int, int]:
|
def _calc_layout(self) -> Tuple[int, int]:
|
||||||
|
|
|
@ -36,7 +36,7 @@ def test_renderer():
|
||||||
cfg = RendererConfig(WIDTH, HEIGHT, ncols=2)
|
cfg = RendererConfig(WIDTH, HEIGHT, ncols=2)
|
||||||
nplots = 16
|
nplots = 16
|
||||||
|
|
||||||
r = MatplotlibRenderer(cfg, nplots, create_window=False)
|
r = MatplotlibRenderer(cfg, nplots)
|
||||||
|
|
||||||
# 2 columns, 8 rows
|
# 2 columns, 8 rows
|
||||||
assert r.ncols == 2
|
assert r.ncols == 2
|
||||||
|
|
Ładowanie…
Reference in New Issue