Skip to content

Commit

Permalink
Refactoring code for Enterprise issue #529 (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
amontanez24 authored May 8, 2024
1 parent 88bf32d commit e1dde65
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions rdt/transformers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,18 @@ def _reverse_transform(self, data):
self.reset_randomization()
remaining = self.generator_size

if remaining >= sample_size:
reverse_transformed = [next(self.generator) for _ in range(sample_size)]
self.generated += sample_size

else:
generated_values = list(self.generator)
reverse_transformed = generated_values[:]
self.generated = self.generator_size
generated_values = []
while len(generated_values) < sample_size:
try:
generated_values.append(next(self.generator))
self.generated += 1
except (RuntimeError, StopIteration):
# Can't generate more rows without collision so breaking out of loop
break

reverse_transformed = generated_values[:]

if len(reverse_transformed) < sample_size:
if self.enforce_uniqueness:
try:
remaining_samples = sample_size - len(reverse_transformed)
Expand Down

0 comments on commit e1dde65

Please sign in to comment.