question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when calling pyfloat provider

See original GitHub issue
  • Faker version: 2.0.4
  • OS: Ubuntu 19.04
  • Python version: 3.7.3

There is a bug in pyfloat provider.

Steps to reproduce

from faker import Faker
fake = Faker()
# just any random float numbers in min_value < max_value
fake.pyfloat(min_value=-15.23, max_value=4512313)

Expected behavior

Above call should not raise any error.

Actual behavior

Running the code above will raise the following error:

....
File "/usr/lib/python3.7/random.py", line 186, in randrange
    raise ValueError("non-integer arg 1 for randrange()")
ValueError: non-integer arg 1 for randrange()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
sciencectncommented, Feb 5, 2021

Looks like we just went to 6.0.0, does this mean we can change the signature of this function and break compatibility?

I think @fcurella’s proposal to drop left_digits and change right_digits to precision makes the most sense. Then allow min_value and max_value to be floats.

I can do the PR if you don’t have anything in the works yet, let me know.

3reactions
github-actions[bot]commented, Apr 21, 2022

This issue was closed because it has been inactive for 14 days since being marked as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Obtaining wrong result when using PyFloat_FromDouble in a ...
I am in the process of learning how to call C functions from Python ... i); if(!PyFloat_Check(tupleItem)){ printf("Error: tuple contains a ...
Read more >
PyValueError in pyo3::exceptions - Rust
Represents Python's ValueError exception. Example: Raising ValueError from Rust. This exception can be sent to Python code by converting it into a PyErr...
Read more >
Floating Point Objects — Python 3.11.1 documentation
If pyfloat is not a Python floating point object but has a __float__() method, this method will first be called to convert pyfloat...
Read more >
Faker - PyPI
Each call to method ``fake.name()`` yields a different (random) result. ... If no localized provider is found, the factory falls back to the...
Read more >
The Python/C API
This method returns -1.0 upon failure, so one should call PyErr_Occurred() to check for errors. double PyFloat_AS_DOUBLE(PyObject *pyfloat).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found