-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mxmn from m4 #342
Mxmn from m4 #342
Changes from 12 commits
d92ff9c
4ad7b07
191b94b
7a33ba6
e977597
920a394
783914c
a425c29
c620517
49c720a
dd2a9f7
03a7940
147ceca
ed2c962
1c56120
be7afda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,10 @@ def chart_maxmin( | |
mn, mx = out | ||
|
||
mx_vlm_in_view = 0 | ||
|
||
# TODO: we need to NOT call this to avoid a manual | ||
# np.max/min trigger and especially on the vlm_chart | ||
# flows which aren't shown.. like vlm? | ||
if vlm_chart: | ||
out = vlm_chart.maxmin() | ||
if out: | ||
|
@@ -416,10 +420,8 @@ def graphics_update_cycle( | |
) | ||
or trigger_all | ||
): | ||
# TODO: we should track and compute whether the last | ||
# pixel in a curve should show new data based on uppx | ||
# and then iff update curves and shift? | ||
chart.increment_view(steps=i_diff) | ||
# chart.increment_view(steps=i_diff + round(append_diff - uppx)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. left this is in because to me the logic makes sense but for whatever reason it doesn't seem to actually be correct based on testing. Ideally we can get to where there's never an error margin on shifts when optimizing for uppx scaling. |
||
|
||
if vlm_chart: | ||
vlm_chart.increment_view(steps=i_diff) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,6 +337,7 @@ class Flow(msgspec.Struct): # , frozen=True): | |
name: str | ||
plot: pg.PlotItem | ||
graphics: Union[Curve, BarItems] | ||
yrange: tuple[float, float] = None | ||
|
||
# in some cases a flow may want to change its | ||
# graphical "type" or, "form" when downsampling, | ||
|
@@ -416,6 +417,10 @@ def maxmin( | |
if not slice_view.size: | ||
mxmn = None | ||
|
||
elif self.yrange: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the bit where we choose to use the m4 yrange output if set instead of the normal "manual" sorting calls from prior. |
||
mxmn = self.yrange | ||
# print(f'{self.name} M4 maxmin: {mxmn}') | ||
|
||
else: | ||
if self.is_ohlc: | ||
ylow = np.min(slice_view['low']) | ||
|
@@ -427,6 +432,7 @@ def maxmin( | |
yhigh = np.max(view) | ||
|
||
mxmn = ylow, yhigh | ||
# print(f'{self.name} MANUAL maxmin: {mxmin}') | ||
|
||
if mxmn is not None: | ||
# cache new mxmn result | ||
|
@@ -628,10 +634,13 @@ def update_graphics( | |
# source data so we clear our path data in prep | ||
# to generate a new one from original source data. | ||
new_sample_rate = True | ||
showing_src_data = True | ||
should_ds = False | ||
should_redraw = True | ||
|
||
showing_src_data = True | ||
# reset yrange to be computed from source data | ||
self.yrange = None | ||
|
||
# MAIN RENDER LOGIC: | ||
# - determine in view data and redraw on range change | ||
# - determine downsampling ops if needed | ||
|
@@ -657,13 +666,20 @@ def update_graphics( | |
|
||
**rkwargs, | ||
) | ||
if showing_src_data: | ||
# print(f"{self.name} SHOWING SOURCE") | ||
# reset yrange to be computed from source data | ||
self.yrange = None | ||
|
||
if not out: | ||
log.warning(f'{self.name} failed to render!?') | ||
return graphics | ||
|
||
path, data, reset = out | ||
|
||
# if self.yrange: | ||
# print(f'flow {self.name} yrange from m4: {self.yrange}') | ||
|
||
# XXX: SUPER UGGGHHH... without this we get stale cache | ||
# graphics that don't update until you downsampler again.. | ||
if reset: | ||
|
@@ -1058,6 +1074,7 @@ def render( | |
# xy-path data transform: convert source data to a format | ||
# able to be passed to a `QPainterPath` rendering routine. | ||
if not len(hist): | ||
# XXX: this might be why the profiler only has exits? | ||
return | ||
|
||
x_out, y_out, connect = self.format_xy( | ||
|
@@ -1144,11 +1161,14 @@ def render( | |
|
||
elif should_ds and uppx > 1: | ||
|
||
x_out, y_out = xy_downsample( | ||
x_out, y_out, ymn, ymx = xy_downsample( | ||
x_out, | ||
y_out, | ||
uppx, | ||
) | ||
self.flow.yrange = ymn, ymx | ||
# print(f'{self.flow.name} post ds: ymn, ymx: {ymn},{ymx}') | ||
|
||
reset = True | ||
profiler(f'FULL PATH downsample redraw={should_ds}') | ||
self._in_ds = True | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -639,20 +639,25 @@ def multi_maxmin( | |
names: list[str], | ||
|
||
) -> tuple[float, float]: | ||
''' | ||
Flows "group" maxmin loop; assumes all named flows | ||
are in the same co-domain and thus can be sorted | ||
as one set. | ||
|
||
Iterates all the named flows and calls the chart | ||
api to find their range values and return. | ||
|
||
TODO: really we should probably have a more built-in API | ||
for this? | ||
|
||
''' | ||
mx = 0 | ||
for name in names: | ||
|
||
mxmn = chart.maxmin(name=name) | ||
if mxmn: | ||
ymax = mxmn[1] | ||
if ymax > mx: | ||
mx = ymax | ||
ymn, ymx = chart.maxmin(name=name) | ||
mx = max(mx, ymx) | ||
|
||
return 0, mx | ||
|
||
chart.view.maxmin = partial(multi_maxmin, names=['volume']) | ||
|
||
# TODO: fix the x-axis label issue where if you put | ||
# the axis on the left it's totally not lined up... | ||
# show volume units value on LHS (for dinkus) | ||
|
@@ -776,12 +781,16 @@ def chart_curves( | |
|
||
) -> None: | ||
for name in names: | ||
|
||
render = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh this can be dropped.. |
||
|
||
if 'dark' in name: | ||
color = dark_vlm_color | ||
elif 'rate' in name: | ||
color = vlm_color | ||
else: | ||
color = 'bracket' | ||
render = True | ||
|
||
curve, _ = chart.draw_curve( | ||
name=name, | ||
|
@@ -799,6 +808,7 @@ def chart_curves( | |
# since only a placeholder of `None` is entered in | ||
# ``.draw_curve()``. | ||
flow = chart._flows[name] | ||
# flow.render = render | ||
assert flow.plot is pi | ||
|
||
chart_curves( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so just to point to the crux of it all, there's really no point in not capturing these summary max/min values during each downsample cycle and this is now what we take an use in place of "manual" y-range sorting on the source data when possible.