MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / slice

Method slice

tensorflow/python/debug/cli/debugger_cli_common.py:230–268  ·  view source on GitHub ↗

Slice a RichTextLines object. The object itself is not changed. A sliced instance is returned. Args: begin: (int) Beginning line index (inclusive). Must be >= 0. end: (int) Ending line index (exclusive). Must be >= 0. Returns: (RichTextLines) Sliced output instance o

(self, begin, end)

Source from the content-addressed store, hash-verified

228 return len(self._lines)
229
230 def slice(self, begin, end):
231 """Slice a RichTextLines object.
232
233 The object itself is not changed. A sliced instance is returned.
234
235 Args:
236 begin: (int) Beginning line index (inclusive). Must be >= 0.
237 end: (int) Ending line index (exclusive). Must be >= 0.
238
239 Returns:
240 (RichTextLines) Sliced output instance of RichTextLines.
241
242 Raises:
243 ValueError: If begin or end is negative.
244 """
245
246 if begin < 0 or end < 0:
247 raise ValueError("Encountered negative index.")
248
249 # Copy lines.
250 lines = self.lines[begin:end]
251
252 # Slice font attribute segments.
253 font_attr_segs = {}
254 for key in self.font_attr_segs:
255 if key >= begin and key < end:
256 font_attr_segs[key - begin] = self.font_attr_segs[key]
257
258 # Slice annotations.
259 annotations = {}
260 for key in self.annotations:
261 if not isinstance(key, int):
262 # Annotations can contain keys that are not line numbers.
263 annotations[key] = self.annotations[key]
264 elif key >= begin and key < end:
265 annotations[key - begin] = self.annotations[key]
266
267 return RichTextLines(
268 lines, font_attr_segs=font_attr_segs, annotations=annotations)
269
270 def extend(self, other):
271 """Extend this instance of RichTextLines with another instance.

Callers 15

_bst_towerMethod · 0.80
_create_modelMethod · 0.80
allgatherFunction · 0.80
test_mpi_allgatherMethod · 0.80
allgatherFunction · 0.80
_extract_statesMethod · 0.80
_model_fnFunction · 0.80
_precision_at_thresholdsFunction · 0.80
_recall_at_thresholdsFunction · 0.80

Calls 1

RichTextLinesClass · 0.85

Tested by 15

test_mpi_allgatherMethod · 0.64
test_oneof_patternMethod · 0.64
input_fnMethod · 0.64
input_fnMethod · 0.64
input_fnMethod · 0.64
input_fnMethod · 0.64
input_fnMethod · 0.64
per_step_batch_lossMethod · 0.64
testSelectAllMethod · 0.64