Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upper limit of nb_elements #2067

Merged

Conversation

mileswatsonbjss
Copy link
Contributor

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 specified variable_nb_elements as False it randomises the number so that it is then between 60% and 140% of the original requested nb_elements.
This would be fine in cases where nb_elements is a number far below the length of the lorem (locale) list but if 140% of the number (nb_elements) is greater than the lorem (locale) list length you may see the error in the issue linked above.

It was also possible see this error when variable_nb_elements is False, if the number of nb_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 to randomize_nb_elements in pydict to cater for both scenarios above. If nb_elements is greater than the length of the lorem (locale) list we set nb_elements to the length of the lorem (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 where variable_nb_elements is True.

Copy link
Collaborator

@fcurella fcurella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fcurella fcurella merged commit b01507a into joke2k:master Jun 26, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants