diff --git a/.coveragerc b/.coveragerc index 8b13789..a18fd12 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1 +1,2 @@ - +[coverage:run] +source = mobility diff --git a/.github/workflows/install-and-test.yml b/.github/workflows/install-and-test.yml index 9a47936..66971c0 100644 --- a/.github/workflows/install-and-test.yml +++ b/.github/workflows/install-and-test.yml @@ -59,4 +59,4 @@ jobs: shell: bash -el {0} - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 diff --git a/pyproject.toml b/pyproject.toml index dd0399e..da7d559 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ classifiers = [ [project.optional-dependencies] dev = [ + "coverage", "flake8", "pytest", "pytest-cov", @@ -78,4 +79,4 @@ mobility = [ [tool.setuptools.packages.find] where = ["."] include = ["mobility*"] -exclude = ["certs", "certs.*"] \ No newline at end of file +exclude = ["certs", "certs.*"] diff --git a/tests/back/integration/test_901_ensure_quickstart_works.py b/tests/back/integration/test_901_ensure_quickstart_works.py new file mode 100644 index 0000000..2fa1193 --- /dev/null +++ b/tests/back/integration/test_901_ensure_quickstart_works.py @@ -0,0 +1,34 @@ +import os +import dotenv + +import mobility + +dotenv.load_dotenv() + +# Using Foix (a small town) and a limited radius for quick results +transport_zones = mobility.TransportZones("fr-09122", radius = 10) + +# Using EMP, the latest national mobility survey for France +emp = mobility.EMPMobilitySurvey() + +# Creating a synthetic population of 1000 for the area +pop = mobility.Population(transport_zones, sample_size = 1000) + +# Simulating the trips for this population for three modes : car, walk and bicyle, and only home and work motives (OtherMotive is mandatory) +pop_trips = mobility.PopulationTrips( + pop, + [mobility.CarMode(transport_zones), mobility.WalkMode(transport_zones), mobility.BicycleMode(transport_zones)], + [mobility.HomeMotive(), mobility.WorkMotive(), mobility.OtherMotive(population=pop)], + [emp], + n_iterations=1 + ) + +# You can get the weekday trips to inspect them +weekday_flows = pop_trips.get()["weekday_flows"].collect() + +# You can can also get global metrics that will be compared to the theoetical values for this population +global_metrics = pop_trips.evaluate("global_metrics") + +# You can also plot the flows, with labels for the cities that are bigger than their neighbours +labels = pop_trips.get_prominent_cities() +pop_trips.plot_od_flows(labels=labels)