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