lk-geimfari / mimesis

Mimesis is a robust data generator for Python that can produce a wide range of fake data in multiple languages.
https://mimesis.name
MIT License
4.39k stars 330 forks source link

Issue with telephone() of provider Personal() #250

Closed lk-geimfari closed 6 years ago

lk-geimfari commented 6 years ago

So, it's returns too many similar data. We need to fix it immediately.

This method is based on the custom_code() method of the Code() provider and it should works like custom_code(), but it doesn't.

How works telephone() now:

>>> from mimesis import Personal

>>> s = {Personal('ru').telephone() for _ in range(2000)}
{'+7-(967)-072-06-28', '+7-(915)-272-71-92', '+7-(937)-072-06-28', ... }
>>> len(s)
14 # Only 14 unique values from 2000.

How it should work:

>>> import random

>>> from mimesis import Code
>>> mask = random.choice([
    "+7-(96#)-###-##-##",
    "+7-(92#)-###-##-##",
    "+7-(93#)-###-##-##",
    "+7-(91#)-###-##-##",
    "+7-(999)-###-##-##",
    "+7-(9##)-###-##-##",
    "+7-(909)-###-##-##",
    "+7-(968)-###-##-##"
])

>>> c = {Code('ru').custom_code(mask=mask) for _ in range(2000)}
{'+7-(921)-395-52-94', '+7-(955)-222-89-60', '+7-(978)-727-56-77', ... }
>>> len(c)
2000 # All values unique.

Similar problems are observed with other methods, such as identifier().

P.S As i can judge, the problem not in a seed.

simba3447 commented 6 years ago

May I start working on this one?

lk-geimfari commented 6 years ago

@sammyshj Sure! You're assigned. Thanks!

lk-geimfari commented 6 years ago

Fixed in #251