Repository: joke2k/faker

Issue:
pyfloat, pydecimal cannot be negative when left_digits=0
I am trying to fake random floats in the range `(-1, 1)`.  Currently, `pyfloat` and `pydecimal` will never be negative as long as `left_digits=0`, even if `positive=False`.

This seems to be because [the `sign` (-1, 1) is multiplied by only the left digits](https://github.com/joke2k/faker/blob/6e32e07/faker/providers/python/__init__.py#L62) (which in this case is 0, canceling out the `sign`), rather than by the entire numeric value.

### Steps to reproduce

```python
>>> import faker
>>> fake = faker.Faker()
>>> any(fake.pyfloat(left_digits=0, positive=False) < 0 for _ in range(10000))
False
```

### Expected behavior

I'd expect approximately half of the floats to be negative, when `positive` is not `True`


Discussion:
ariksu: Frankly, I have no idea why coverage reduced. Looks like there are some uncovered or luck-based case for domain testing and cli exceptions. I believe that some additional tests would fix that, but those are out of scope for this commit.
fcurella: Thank you! ✨ 

Patch:
diff --git a/faker/providers/python/__init__.py b/faker/providers/python/__init__.py
index ed9f9793..6b8d4bcf 100644
--- a/faker/providers/python/__init__.py
+++ b/faker/providers/python/__init__.py
@@ -53,8 +53,7 @@ class Provider(BaseProvider):
             self.random_int(1, sys.float_info.dig))
         right_digits = right_digits if right_digits is not None else (
             self.random_int(0, sys.float_info.dig - left_digits))
-        sign = 1 if positive else self.random_element((-1, 1))
-
+        sign = ''
         if (min_value is not None) or (max_value is not None):
             if min_value is None:
                 min_value = max_value - self.random_int()
@@ -63,9 +62,11 @@ class Provider(BaseProvider):
 
             left_number = self.random_int(min_value, max_value)
         else:
-            left_number = sign * self.random_number(left_digits)
+            sign = '+' if positive else self.random_element(('+', '-'))
+            left_number = self.random_number(left_digits)
 
-        return float("{0}.{1}".format(
+        return float("{0}{1}.{2}".format(
+            sign,
             left_number,
             self.random_number(right_digits),
         ))


Test patch:
diff --git a/tests/test_factory.py b/tests/test_factory.py
index 6336b9ea..daca7957 100644
--- a/tests/test_factory.py
+++ b/tests/test_factory.py
@@ -460,6 +460,13 @@ class FactoryTestCase(unittest.TestCase):
         with pytest.raises(ValueError):
             provider.pyfloat(left_digits=0, right_digits=0)
 
+    def test_negative_pyfloat(self):
+        # tests for https://github.com/joke2k/faker/issues/813
+        factory = Faker()
+        factory.seed_instance(32167)
+        assert any(factory.pyfloat(left_digits=0, positive=False) < 0 for _ in range(100))
+        assert any(factory.pydecimal(left_digits=0, positive=False) < 0 for _ in range(100))
+
     def test_us_ssn_valid(self):
         from faker.providers.ssn.en_US import Provider