@@ -88,6 +88,9 @@ def __eq__(self, other: object) -> bool:
8888 return False
8989 return self ._randomSeed == other ._randomSeed
9090
91+ def __hash__ (self ) -> int :
92+ return hash (self ._randomSeed )
93+
9194 def withRandomSeed (self , seed : int ) -> "TextGenerator" :
9295 """
9396 Sets the TextGenerator's random seed.
@@ -148,7 +151,7 @@ def compactNumpyTypeForValues(listValues: list | numpy.ndarray) -> np.dtype:
148151 retval = np .dtype ("B" )
149152 else :
150153 # compute bytes required and raise to nearest power of 2
151- bytesRequired = int ( math .ceil (bits_required / 8.0 ) )
154+ bytesRequired = math .ceil (bits_required / 8.0 )
152155 retval = np .dtype (f"u{ bytesRequired } " )
153156 return retval
154157
@@ -386,7 +389,7 @@ def pandasGenerateText(self, v: pd.Series) -> pd.Series:
386389 placeholders = np .full ((v .shape [0 ], self ._max_placeholders ), "" , dtype = np .object_ )
387390
388391 # prepare template selections, bounds, rnd values to drive application of algorithm
389- template_choices , template_rnd_bounds , template_rnds = self ._prepare_random_bounds (v )
392+ template_choices , _ , template_rnds = self ._prepare_random_bounds (v )
390393 template_choices_t = template_choices .T
391394
392395 # create masked arrays, with all elements initially masked
@@ -516,7 +519,7 @@ def _prepareTemplateStrings(self, genTemplate: str, escapeSpecialMeaning: bool =
516519 use_value = False
517520 elif (char in self ._templateMappings ) and (not escape ) ^ escapeSpecialMeaning :
518521 # handle case for ['a','A','k', 'K', 'x', 'X']
519- bound , mappingArr = self ._templateMappings [char ]
522+ bound , _ = self ._templateMappings [char ]
520523 retval .append (bound )
521524 num_placeholders += 1
522525 escape = False
@@ -655,7 +658,7 @@ def _get_values_subelement(elem: int) -> np.ndarray:
655658 elif char in regular_keys and (not escape ) ^ escapeSpecialMeaning :
656659 # note vectorized lookup - `rnds[:, rnd_offset]` will get vertical column of
657660 # random numbers from `rnds` 2d array
658- bound , value_mappings = self ._templateMappings [char ]
661+ _ , value_mappings = self ._templateMappings [char ]
659662
660663 if unmasked_rows is not None :
661664 placeholders [unmasked_rows , num_placeholders ] = value_mappings [rnds [unmasked_rows , rnd_offset ]]
@@ -841,7 +844,7 @@ def generateText(self, baseValues: list | pd.Series | np.ndarray, rowCount: int
841844 # for example - if number of good words is 3 and sentence is index array of [0, 1, 2, 3, 4, 5 ,6]
842845 # then mask is produced via conditions indices <= good_word
843846 # note value of True means masked for numpy
844- r , p , s , w = np .indices (output_shape )
847+ _ , p , s , w = np .indices (output_shape )
845848
846849 good_words = para_stats [:, :, :, 2 ]
847850 good_paragraphs = para_stats [:, :, :, 0 ]
0 commit comments