dkotschessa / faker_airtravel Goto Github PK
View Code? Open in Web Editor NEWA community provider for the python faker library to fake airline data for testing purposes.
Home Page: https://pypi.org/project/faker_airtravel/
License: MIT License
A community provider for the python faker library to fake airline data for testing purposes.
Home Page: https://pypi.org/project/faker_airtravel/
License: MIT License
Hey ๐
I was looking into the source code of this project, namely AirTravelProvider
(source) and I noticed that the random generation uses python's random
, rather than the shared random
in generator. This raises a reproducibility concern (among others), namely the provider not following the seed set by Generator.seed(<seed>)
.
Update the provider, replacing random.*
usages by self.generator.random.*
(example).
I'm open to create a PR with the proposed solution ๐
Hi, im aware of using python script to generate airport data like:
python -c "from faker import Faker; from faker_airtravel import AirTravelProvider; fake = Faker(); fake.add_provider(AirTravelProvider); airports = [fake.airport_name() for _ in range(10)]; print(airports)"
and returns as expected:
['Kahului airport', 'Taiyuan Wusu airport', 'Carriel Sur International airport', 'Fukuoka airport', 'Gustavia airport', 'Santa Maria airport', 'Salta airport', 'Tacoma International airport', 'Camilo Daza airport', 'Senador Nilo Coelho airport']
$ faker -i faker_airtravel airport_name
AttributeError: module 'faker_airtravel' has no attribute 'Provider'
$ faker -i faker_airtravel.AirTravelProvider airport_name
ModuleNotFoundError: No module named 'faker_airtravel.AirTravelProvider'
$ faker -i AirTravelProvider airport_name
ModuleNotFoundError: No module named 'AirTravelProvider'
Thanks (and sorry as this is not really an issue with faker_airtravel, but google only returns python examples and couldn't find command line example executing faker with -i to add community provider.
2- additionally I installed faker_airtravel via pip, but couldn't understand how to install via conda, seems i need to specify some "channel", i wonder how to do that (I'm not hard core python developer). Heres pip install ok:
$ pip install faker_airtravel
Collecting faker_airtravel
Using cached faker_airtravel-0.4-py2.py3-none-any.whl (18 kB)
Installing collected packages: faker_airtravel
Successfully installed faker_airtravel-0.4
And conda giving error about channel:
$ conda install faker_airtravel
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- faker_airtravel
Current channels:
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
I think a great option would be to restrict flights from and to specific countries.
An example would be: Flights from USA and airports LAX or DFW as an example.
Code to reproduce:
from faker import Faker
from faker_airtravel import AirTravelProvider
fake = Faker()
for provider in (AirTravelProvider, ):
fake.add_provider(provider)
for _ in range(10_000):
random_flight = fake.flight()
d_iata = random_flight["origin"]["iata"]
a_iata = random_flight["destination"]["iata"]
print(f'{random_flight["origin"]} -> {random_flight["destination"]}')
assert d_iata != a_iata
"Origin" and "destination" may be the same.
UPD:
You use random.choices
. It will not give you elements without repetition out of the box. This is why the bug appears.
put the headers in just like: https://github.com/okken/submark/blob/master/README.md
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.