MCPcopy Index your code
hub / github.com/QData/TextAttack / _get_worklist

Method _get_worklist

textattack/attacker.py:92–103  ·  view source on GitHub ↗
(self, start, end, num_examples, shuffle)

Source from the content-addressed store, hash-verified

90 self._checkpoint = None
91
92 def _get_worklist(self, start, end, num_examples, shuffle):
93 if end - start < num_examples:
94 logger.warn(
95 f"Attempting to attack {num_examples} samples when only {end - start} are available."
96 )
97 candidates = list(range(start, end))
98 if shuffle:
99 random.shuffle(candidates)
100 worklist = collections.deque(candidates[:num_examples])
101 candidates = collections.deque(candidates[num_examples:])
102 assert (len(worklist) + len(candidates)) == (end - start)
103 return worklist, candidates
104
105 def _attack(self):
106 """Internal method that carries out attack.

Callers 2

_attackMethod · 0.95
_attack_parallelMethod · 0.95

Calls 1

shuffleMethod · 0.45

Tested by

no test coverage detected