MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / update

Method update

src/__init__.py:16206–16241  ·  view source on GitHub ↗

Evaluates `more, _ = self.place(fn(parameter))`. If `more` is false, then `rect` is big enough to contain `self` and we set `state.pmax=parameter` and return True. Otherwise we set `state.pmin=parameter` and return False.

(parameter)

Source from the content-addressed store, hash-verified

16204 return result
16205
16206 def update(parameter):
16207 '''
16208 Evaluates `more, _ = self.place(fn(parameter))`. If `more` is
16209 false, then `rect` is big enough to contain `self` and we
16210 set `state.pmax=parameter` and return True. Otherwise we set
16211 `state.pmin=parameter` and return False.
16212 '''
16213 rect = fn(parameter)
16214 assert isinstance(rect, Rect), f'{type(rect)=} {rect=}'
16215 if rect.is_empty:
16216 big_enough = False
16217 result = Story.FitResult(parameter=parameter, numcalls=state.numcalls)
16218 if verbose:
16219 log(f'update(): not calling self.place() because rect is empty.')
16220 else:
16221 more, filled = self.place(rect, flags)
16222 state.numcalls += 1
16223 big_enough = not more
16224 result = Story.FitResult(
16225 filled=filled,
16226 more=more,
16227 numcalls=state.numcalls,
16228 parameter=parameter,
16229 rect=rect,
16230 big_enough=big_enough,
16231 )
16232 if verbose:
16233 log(f'update(): called self.place(): {state.numcalls:>2d}: {more=} {parameter=} {rect=}.')
16234 if big_enough:
16235 state.pmax = parameter
16236 state.pmax_result = result
16237 else:
16238 state.pmin = parameter
16239 state.pmin_result = result
16240 state.last_p = parameter
16241 return big_enough
16242
16243 def opposite(p, direction):
16244 '''

Callers

nothing calls this directly

Calls 2

placeMethod · 0.95
logFunction · 0.70

Tested by

no test coverage detected