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

pyfloat ignores the positive kwarg #1928

Closed
marcosschroh opened this issue Oct 13, 2023 · 1 comment · Fixed by #1954
Closed

pyfloat ignores the positive kwarg #1928

marcosschroh opened this issue Oct 13, 2023 · 1 comment · Fixed by #1954

Comments

@marcosschroh
Copy link

marcosschroh commented Oct 13, 2023

  • Faker version: Faker==19.10.0
  • OS: MacOs 13.3.1
  • python version: 3.11

Brief summary of the issue goes here.

pyfloat ignores the positive kwarg. When setting the flag to False I expect that the fake results will be no positive

Steps to reproduce

import faker

f = faker.Faker()

fake.pyfloat(positive=False)

In [9]: f.pyfloat(positive=False)
Out[9]: 989.306591673515

In [10]: f.pyfloat(positive=False)
Out[10]: 2202.72694698392

In [11]: f.pyfloat(positive=False)
Out[11]: 3824832.83198619

In [12]: f.pyfloat(positive=False)
Out[12]: 25312785206442.4

In [13]: f.pyfloat(positive=False)
Out[13]: 4906363.78374671

In [14]: f.pyfloat(positive=False)
Out[14]: -593.480996281136

In [15]: f.pyfloat(positive=False)
Out[15]: -15794267.4477139

Expected behavior

If I use positive=False then I expect all the results should be negative

Actual behavior

Results are positive and negative

@viraj-s15
Copy link
Contributor

Seems to be because of this, it just picks the sign randomly if positive is false.

sign = "+" if positive else self.random_element(("+", "-"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants