MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / _find_reduce_close

Function _find_reduce_close

benchmarking/insert_proton_records.py:167–178  ·  view source on GitHub ↗

Find the closing line of the last tt.reduce block. Returns the index of the `}) : ...` line after tt.reduce.return.

(lines: list[str])

Source from the content-addressed store, hash-verified

165
166
167def _find_reduce_close(lines: list[str]) -> int | None:
168 """Find the closing line of the last tt.reduce block.
169
170 Returns the index of the `}) : ...` line after tt.reduce.return.
171 """
172 last_reduce_return = _find_last(lines, "tt.reduce.return")
173 if last_reduce_return is None:
174 return None
175 for i in range(last_reduce_return + 1, len(lines)):
176 if re.search(r"\}\)", lines[i]):
177 return i
178 return None
179
180
181def _find_first(lines: list[str], pattern: str) -> int | None:

Callers 1

_find_insertion_pointsFunction · 0.85

Calls 1

_find_lastFunction · 0.85

Tested by

no test coverage detected