-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
pyfloat
with positive=True
and max_value
produces unexpected results.
#1212
Comments
coiax
added a commit
to coiax/faker
that referenced
this issue
Jul 21, 2020
When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes joke2k#1212.
fcurella
pushed a commit
that referenced
this issue
Jul 22, 2020
* 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes #1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended.
fcurella
pushed a commit
that referenced
this issue
Aug 4, 2020
* 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes #1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended.
fcurella
added a commit
that referenced
this issue
Aug 17, 2020
* Extend Person Provider to support nonbinary suffixes and prefixes (#1206) * Implement nonbinary Person Provider * Address flake8 and isort findings * Fix import ordering in tests * Add tests for en Provider to test preexisting suffix scenario * Refine tests for en Provider * Close #1208. Update setup.py `python_requires` * Add safe domain names (#1209) * Add safe_domain_name() to Internet Provider * Apply DRY to safe domain generation * Add a test for safe email generation * Update __init__.py (#1217) some grammar fix * 💂 Fix max_value/positive pyfloat interaction (#1218) * 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes #1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended. * Update bban_format for country FI (#1220) Fixes #1219. * Fix person.ja_JP kana and roman characters (#1221) * Add ja_JP kana_names * Reformat and Add links * fix PEP8 * JSON and Fixed_Width Structures (#1223) * Builder module * Move to Misc as Methods * Allow JSON to produce single entry * json and fixed_width tests * Improved structure creation and tests * correcting E231 * Value only lists * fix E303 * Improved docstrings * Parser Arguments * Strip not require * Better description of error * Format Parser with Caching * Correct import position * Better handing of white space * Refinement and Tests * Replace parser with format argument token * Use format name only if found * Fix Flake8 E231 * Remove JSON * Add Argument Group Methods * Change Add to Set, Correct Tests * Fix Flake8 C812 Co-authored-by: Cory Donnelly <[email protected]> Co-authored-by: Flavio Curella <[email protected]> Co-authored-by: Pavel E. Petrov <[email protected]> Co-authored-by: coiax <[email protected]> Co-authored-by: ALMP-SallaH <[email protected]> Co-authored-by: Yohei Ema <[email protected]>
fcurella
added a commit
that referenced
this issue
Aug 19, 2020
* Extend Person Provider to support nonbinary suffixes and prefixes (#1206) * Implement nonbinary Person Provider * Address flake8 and isort findings * Fix import ordering in tests * Add tests for en Provider to test preexisting suffix scenario * Refine tests for en Provider * Close #1208. Update setup.py `python_requires` * Add safe domain names (#1209) * Add safe_domain_name() to Internet Provider * Apply DRY to safe domain generation * Add a test for safe email generation * Update __init__.py (#1217) some grammar fix * 💂 Fix max_value/positive pyfloat interaction (#1218) * 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes #1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended. * Update bban_format for country FI (#1220) Fixes #1219. * Fix person.ja_JP kana and roman characters (#1221) * Add ja_JP kana_names * Reformat and Add links * fix PEP8 * JSON and Fixed_Width Structures (#1223) * Builder module * Move to Misc as Methods * Allow JSON to produce single entry * json and fixed_width tests * Improved structure creation and tests * correcting E231 * Value only lists * fix E303 * Improved docstrings * Add Argument Group references * Add Argument Group and Parser Support * Fixed handing of integers and floats * Addressed Flake8 findings * Better Examples and Samples Co-authored-by: Cory Donnelly <[email protected]> Co-authored-by: Flavio Curella <[email protected]> Co-authored-by: Pavel E. Petrov <[email protected]> Co-authored-by: coiax <[email protected]> Co-authored-by: ALMP-SallaH <[email protected]> Co-authored-by: Yohei Ema <[email protected]>
IlfirinPL
pushed a commit
to IlfirinPL/faker
that referenced
this issue
Apr 9, 2021
* 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes joke2k#1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended.
IlfirinPL
pushed a commit
to IlfirinPL/faker
that referenced
this issue
Apr 9, 2021
* Extend Person Provider to support nonbinary suffixes and prefixes (joke2k#1206) * Implement nonbinary Person Provider * Address flake8 and isort findings * Fix import ordering in tests * Add tests for en Provider to test preexisting suffix scenario * Refine tests for en Provider * Close joke2k#1208. Update setup.py `python_requires` * Add safe domain names (joke2k#1209) * Add safe_domain_name() to Internet Provider * Apply DRY to safe domain generation * Add a test for safe email generation * Update __init__.py (joke2k#1217) some grammar fix * 💂 Fix max_value/positive pyfloat interaction (joke2k#1218) * 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes joke2k#1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended. * Update bban_format for country FI (joke2k#1220) Fixes joke2k#1219. * Fix person.ja_JP kana and roman characters (joke2k#1221) * Add ja_JP kana_names * Reformat and Add links * fix PEP8 * JSON and Fixed_Width Structures (joke2k#1223) * Builder module * Move to Misc as Methods * Allow JSON to produce single entry * json and fixed_width tests * Improved structure creation and tests * correcting E231 * Value only lists * fix E303 * Improved docstrings * Parser Arguments * Strip not require * Better description of error * Format Parser with Caching * Correct import position * Better handing of white space * Refinement and Tests * Replace parser with format argument token * Use format name only if found * Fix Flake8 E231 * Remove JSON * Add Argument Group Methods * Change Add to Set, Correct Tests * Fix Flake8 C812 Co-authored-by: Cory Donnelly <[email protected]> Co-authored-by: Flavio Curella <[email protected]> Co-authored-by: Pavel E. Petrov <[email protected]> Co-authored-by: coiax <[email protected]> Co-authored-by: ALMP-SallaH <[email protected]> Co-authored-by: Yohei Ema <[email protected]>
IlfirinPL
pushed a commit
to IlfirinPL/faker
that referenced
this issue
Apr 9, 2021
* Extend Person Provider to support nonbinary suffixes and prefixes (joke2k#1206) * Implement nonbinary Person Provider * Address flake8 and isort findings * Fix import ordering in tests * Add tests for en Provider to test preexisting suffix scenario * Refine tests for en Provider * Close joke2k#1208. Update setup.py `python_requires` * Add safe domain names (joke2k#1209) * Add safe_domain_name() to Internet Provider * Apply DRY to safe domain generation * Add a test for safe email generation * Update __init__.py (joke2k#1217) some grammar fix * 💂 Fix max_value/positive pyfloat interaction (joke2k#1218) * 💂 Fix max_value/positive pyfloat interaction When pyfloat(max_value=100, positive=True) is called, it sometimes returns negative numbers, which is unexpected. To fix it, we just need to "cap" our internal minimum value to zero. This does leave `pyfloat(max_value=100, min_value=-100, positive=True)` as a call that secretly moves the min_value up to 0 though. Fixes joke2k#1212. * 💥 Forbid pyfloat call with incompatible arguments `pyfloat(positive=True, min_value=-1)` will now throw a ValueError, since the combination of a request for a positive number, yet a negative minimum value is probably not what the caller intended. * Update bban_format for country FI (joke2k#1220) Fixes joke2k#1219. * Fix person.ja_JP kana and roman characters (joke2k#1221) * Add ja_JP kana_names * Reformat and Add links * fix PEP8 * JSON and Fixed_Width Structures (joke2k#1223) * Builder module * Move to Misc as Methods * Allow JSON to produce single entry * json and fixed_width tests * Improved structure creation and tests * correcting E231 * Value only lists * fix E303 * Improved docstrings * Add Argument Group references * Add Argument Group and Parser Support * Fixed handing of integers and floats * Addressed Flake8 findings * Better Examples and Samples Co-authored-by: Cory Donnelly <[email protected]> Co-authored-by: Flavio Curella <[email protected]> Co-authored-by: Pavel E. Petrov <[email protected]> Co-authored-by: coiax <[email protected]> Co-authored-by: ALMP-SallaH <[email protected]> Co-authored-by: Yohei Ema <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using the
pyfloat
provider with bothpositive=True
andmax_value
set, it sometimes produces negative numbers.Steps to reproduce
Expected behavior
Should print some number in (0, 100).
Actual behavior
Prints
-1039.2931776
.The text was updated successfully, but these errors were encountered: