Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this change
Fixes the upper limit of nb_elements
What was wrong
see #2045
How this fixes it
When requesting a high number of nb_elements when calling
pydict
, unless you specifiedvariable_nb_elements
asFalse
it randomises the number so that it is then between 60% and 140% of the original requestednb_elements
.This would be fine in cases where
nb_elements
is a number far below the length of thelorem
(locale) list but if 140% of the number (nb_elements
) is greater than thelorem
(locale) list length you may see the error in the issue linked above.It was also possible see this error when
variable_nb_elements
isFalse
, if the number ofnb_elements
is greater than the length of the lorem (locale) list length.The fix we have added compares the length of the
nb_elements
to the length of the lorem (locale) list after the call torandomize_nb_elements
inpydict
to cater for both scenarios above. Ifnb_elements
is greater than the length of thelorem
(locale) list we setnb_elements
to the length of thelorem
(locale) list, also making the user aware of the fact that this has happened through a warning, else we use the number provided by the user (nb_elements
) or by the randomisation function in cases wherevariable_nb_elements
isTrue
.