Simplify `Flow.maxmin()` block logics
parent
ed2c962bb9
commit
1c561207f5
|
@ -387,10 +387,11 @@ class Flow(msgspec.Struct): # , frozen=True):
|
||||||
lbar: int,
|
lbar: int,
|
||||||
rbar: int,
|
rbar: int,
|
||||||
|
|
||||||
) -> tuple[float, float]:
|
) -> Optional[tuple[float, float]]:
|
||||||
'''
|
'''
|
||||||
Compute the cached max and min y-range values for a given
|
Compute the cached max and min y-range values for a given
|
||||||
x-range determined by ``lbar`` and ``rbar``.
|
x-range determined by ``lbar`` and ``rbar`` or ``None``
|
||||||
|
if no range can be determined (yet).
|
||||||
|
|
||||||
'''
|
'''
|
||||||
rkey = (lbar, rbar)
|
rkey = (lbar, rbar)
|
||||||
|
@ -400,9 +401,8 @@ class Flow(msgspec.Struct): # , frozen=True):
|
||||||
|
|
||||||
shm = self.shm
|
shm = self.shm
|
||||||
if shm is None:
|
if shm is None:
|
||||||
mxmn = None
|
return None
|
||||||
|
|
||||||
else: # new block for profiling?..
|
|
||||||
arr = shm.array
|
arr = shm.array
|
||||||
|
|
||||||
# build relative indexes into shm array
|
# build relative indexes into shm array
|
||||||
|
@ -415,7 +415,7 @@ class Flow(msgspec.Struct): # , frozen=True):
|
||||||
]
|
]
|
||||||
|
|
||||||
if not slice_view.size:
|
if not slice_view.size:
|
||||||
mxmn = None
|
return None
|
||||||
|
|
||||||
elif self.yrange:
|
elif self.yrange:
|
||||||
mxmn = self.yrange
|
mxmn = self.yrange
|
||||||
|
@ -434,8 +434,8 @@ class Flow(msgspec.Struct): # , frozen=True):
|
||||||
mxmn = ylow, yhigh
|
mxmn = ylow, yhigh
|
||||||
# print(f'{self.name} MANUAL maxmin: {mxmin}')
|
# print(f'{self.name} MANUAL maxmin: {mxmin}')
|
||||||
|
|
||||||
if mxmn is not None:
|
# cache result for input range
|
||||||
# cache new mxmn result
|
assert mxmn
|
||||||
self._mxmns[rkey] = mxmn
|
self._mxmns[rkey] = mxmn
|
||||||
|
|
||||||
return mxmn
|
return mxmn
|
||||||
|
|
Loading…
Reference in New Issue