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.

pydecimal provider with positive=True sometimes returns zero

See original GitHub issue
  • Faker version: 13.3.4
  • OS: Ubuntu 18.04.6

Call pydecimal with positive=True, and it’ll sometimes return a zero.

Steps to reproduce

Here’s an example:

import faker

f = faker.Faker()
are_zero = [f.pydecimal(positive=True, right_digits=0) == 0 for _ in range(1000)]
print(any(are_zero))

Expected behavior

It should always print False.

Actual behavior

Sometimes it’s True with f.pydecimal() returning zero.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fcurellacommented, May 16, 2022

@Tayum Thanks, I wasn’t aware of Decimal.next_plus().

@jhbuhrman I agree with everything you said. pydecimal needs be locale-aware, which means we’ll need an additional python provider for nl_BE and fr_BE, at least.

In the docs, we’ll also have to mention that the meaning of positive is locale-dependent. I don’t think most people realize that.

0reactions
github-actions[bot]commented, Aug 30, 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

Error when calling pyfloat provider · Issue #1068 · joke2k/faker
I try to dynamically call these methods and I cannot provide the proper argument's type. New method signature: def pydecimal(self, left_digits: int=None, ...
Read more >
faker.providers.python — Faker 15.3.4 documentation
Returns a random enum of the provided input Enum type. Parameters: enum_cls – The Enum type to produce the value for. Returns: A...
Read more >
pydecimal provider with positive=True sometimes returns zero issue ...
Faker version: 13.3.4; OS: Ubuntu 18.04.6. Call pydecimal with positive=True , and it'll sometimes return a zero. Steps to reproduce. Here's an example:...
Read more >
faker Changelog - PyUp.io
Improve randomness of ``pydecimal`` for different scenarios. ... 6.0.0. * Fix ``pyfloat`` returning zeros when positive=True. Thanks sciencectn.
Read more >
faker - bytemeta
pydecimal provider with positive=True sometimes returns zero · Add `es_CL` providers · Faker produces different results when using pytest even with seed.
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