From 56c065e9a1f2adb2eae6566a451c73ebfb3ec005 Mon Sep 17 00:00:00 2001 From: "John T. Myers" <9696606+johntmyers@users.noreply.github.com> Date: Tue, 4 Aug 2020 17:32:56 -0400 Subject: [PATCH] set generator back to previous state, update var name (#43) Co-authored-by: John Myers --- src/gretel_synthetics/generator.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gretel_synthetics/generator.py b/src/gretel_synthetics/generator.py index eb03035b..8b37421f 100644 --- a/src/gretel_synthetics/generator.py +++ b/src/gretel_synthetics/generator.py @@ -162,8 +162,8 @@ def generate_next(self, num_lines: int) -> Iterable[gen_text]: Yields: A ``gen_text`` object for every line (valid or invalid) that is generated. """ - lines_generated = 0 - while lines_generated < num_lines: + valid_lines_generated = 0 + while valid_lines_generated < num_lines: rec = _predict_chars(self.model, self.sp, self.settings.start_string, self.settings.config).data _valid = None try: @@ -180,14 +180,13 @@ def generate_next(self, num_lines: int) -> Iterable[gen_text]: except Exception as err: # NOTE: this catches any exception raised by the line validator, which # also creates an invalid record - lines_generated += 1 self.total_invalid += 1 yield gen_text(text=rec, valid=False, explain=str(err), delimiter=self.delim) else: if self.settings.line_validator and _valid: - lines_generated += 1 + valid_lines_generated += 1 elif not self.settings.line_validator: - lines_generated += 1 + valid_lines_generated += 1 else: ...