Expose a `force_reformat: bool` up through graphics stack

basic_buy_bot
Tyler Goodlet 2023-06-06 17:22:50 -04:00
parent 4f4860cfb0
commit 6dc3ed8d6a
3 changed files with 19 additions and 3 deletions

View File

@ -222,6 +222,7 @@ class IncrementalFormatter(msgspec.Struct):
profiler: Profiler, profiler: Profiler,
slice_to_inview: bool = True, slice_to_inview: bool = True,
force_full_realloc: bool = False,
) -> tuple[ ) -> tuple[
np.ndarray, np.ndarray,
@ -248,7 +249,10 @@ class IncrementalFormatter(msgspec.Struct):
# we first need to allocate xy data arrays # we first need to allocate xy data arrays
# from the source data. # from the source data.
if self.y_nd is None: if (
self.y_nd is None
or force_full_realloc
):
self.xy_nd_start = shm._first.value self.xy_nd_start = shm._first.value
self.xy_nd_stop = shm._last.value self.xy_nd_stop = shm._last.value
self.x_nd, self.y_nd = self.allocate_xy_nd( self.x_nd, self.y_nd = self.allocate_xy_nd(

View File

@ -752,6 +752,7 @@ class Viz(Struct):
profiler: Profiler | None = None, profiler: Profiler | None = None,
do_append: bool = True, do_append: bool = True,
force_redraw: bool = False,
**kwargs, **kwargs,
@ -796,7 +797,7 @@ class Viz(Struct):
graphics, graphics,
) )
should_redraw: bool = False should_redraw: bool = force_redraw or False
ds_allowed: bool = True # guard for m4 activation ds_allowed: bool = True # guard for m4 activation
# TODO: probably specialize ``Renderer`` types instead of # TODO: probably specialize ``Renderer`` types instead of
@ -906,6 +907,11 @@ class Viz(Struct):
should_ds=should_ds, should_ds=should_ds,
showing_src_data=showing_src_data, showing_src_data=showing_src_data,
# XXX: reallocate entire underlying "format graphics array"
# whenever the caller insists, such as on history
# backfills.
force_reformat=force_redraw,
do_append=do_append, do_append=do_append,
) )
@ -925,6 +931,7 @@ class Viz(Struct):
reset_cache = False reset_cache = False
if ( if (
reset_cache reset_cache
or should_redraw
): ):
# assign output paths to graphicis obj but # assign output paths to graphicis obj but
# after a coords-cache reset. # after a coords-cache reset.

View File

@ -136,6 +136,7 @@ class Renderer(msgspec.Struct):
do_append: bool = True, do_append: bool = True,
use_fpath: bool = True, use_fpath: bool = True,
force_reformat: bool = False,
# only render datums "in view" of the ``ChartView`` # only render datums "in view" of the ``ChartView``
use_vr: bool = True, use_vr: bool = True,
@ -174,6 +175,7 @@ class Renderer(msgspec.Struct):
profiler, profiler,
slice_to_inview=use_vr, slice_to_inview=use_vr,
force_full_realloc=force_reformat,
) )
# no history in view case # no history in view case
@ -222,7 +224,10 @@ class Renderer(msgspec.Struct):
or should_redraw or should_redraw
): ):
# print(f"{self.viz.name} -> REDRAWING BRUH") # print(f"{self.viz.name} -> REDRAWING BRUH")
if new_sample_rate and showing_src_data: if (
new_sample_rate
and showing_src_data
):
log.info(f'DE-downsampling -> {array_key}') log.info(f'DE-downsampling -> {array_key}')
self._in_ds = False self._in_ds = False