Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 14 additions & 2 deletions .github/workflows/test-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,22 @@ jobs:
python -m flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
shell: bash -el {0}

- name: Test with pytest
- name: Test unit with pytest
if: ${{ !inputs.use_min_dep_versions }}
run: |
python -m pytest --cov=mobility --cov-config=.coveragerc --cov-report=xml:coverage.xml --log-cli-level=INFO --clear_inputs
python -m pytest tests/back/unit --cov=mobility --cov-config=.coveragerc --cov-append --log-cli-level=INFO --clear_inputs
shell: bash -el {0}

- name: Test integration with pytest
if: ${{ !inputs.use_min_dep_versions }}
run: |
python -m pytest tests/back/integration --cov=mobility --cov-config=.coveragerc --cov-append --log-cli-level=INFO --clear_inputs
shell: bash -el {0}

- name: Build coverage report
if: ${{ !inputs.use_min_dep_versions }}
run: |
python -m coverage xml -o coverage.xml
shell: bash -el {0}

- name: Test with pytest without coverage
Expand Down
42 changes: 23 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ ipython_config.py
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

Expand Down Expand Up @@ -151,6 +159,15 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Poetry local configuration file
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

# History files
.Rhistory
.Rapp.history
Expand Down Expand Up @@ -198,29 +215,16 @@ po/*~
# RStudio Connect folder
rsconnect/

# Input data files
mobility/data/surveys/emp-2019/*
!mobility/data/surveys/emp-2019/.gitkeep

mobility/data/surveys/entd-2008/*
!mobility/data/surveys/entd-2008/.gitkeep

mobility/data/insee/work/*
mobility/data/insee/facilities/*
mobility/data/insee/esane/*
mobility/data/insee/work_home_flows/*

mobility/data/ign/admin-express/*
mobility/data/insee/territories/UU2020_au_01-01-2023.xlsx
.Rproj.user

# R package: bookdown caching files
/*_files/

**/.env

.DS_Store

certs/
nngeo-master
front/gtfsrouter-main

.vscode/
.vscode/

# Local scratch file created while refreshing ignore rules
.gitignore-new
2 changes: 1 addition & 1 deletion docs/source/modes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ Functions
You must describe the transport modes that you want to model. Most usual modes are available, and you can use a combination of any mode with public transport.
Available modes : walk, bicycle, car, carpool, public transport (+any mode before or after using public transport).

.. automodule:: mobility.transport_modes
.. automodule:: mobility.transport.modes
:members:
14 changes: 5 additions & 9 deletions docs/source/radiation_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
Radiation model
================

With the implementation of the radiation model developed in
`Liu et Yan 2020 <https://www.nature.com/articles/s41598-020-61613-y>`_,
you can reproduce spatially the mobility flows linked to a purpose
(such as home-work trips).
The legacy radiation model module was removed from the package during the
refactor and is no longer part of the documented public API.

.. automodule:: mobility.radiation_model
:members:

This radiation model could be used for any contiguous subset of French departments.
You can find an example of this model in <https://github.com/mobility-team/mobility/tree/main/examples/Millau>.
Older examples may still reference it historically, but this page is kept only
to avoid broken documentation links while the replacement workflow is being
documented.
2 changes: 1 addition & 1 deletion docs/source/set_params.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Set parameters

Use set_params to define the folders you want to work, to initiate the R libraries or to debug your code.

.. automodule:: mobility.set_params
.. automodule:: mobility.config
:members:
6 changes: 3 additions & 3 deletions docs/source/transport_zones.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Transport zones

Use TransportZones to define the area that will be covered by your model.

.. automodule:: mobility.transport_zones
.. automodule:: mobility.spatial.transport_zones
:members:

The TransportZones will call the StudyArea class to manage data in the area.

.. automodule:: mobility.study_area
.. automodule:: mobility.spatial.study_area
:members:


StudyArea will itself call the LocalAdminUnits class to grab data from the local admin units.

.. automodule:: mobility.parsers.local_admin_units
.. automodule:: mobility.spatial.local_admin_units
:members:
45 changes: 14 additions & 31 deletions docs/source/trips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,42 @@ Trips
================

----------------
PopulationTrips
GroupDayTrips
----------------

Trips for a given population can be generated using the class ``population_trips``.
Group-level day plans for a given population can be generated using
the class ``GroupDayTrips``.

.. automodule:: mobility.choice_models.population_trips
.. automodule:: mobility.trips.group_day_trips
:members:

Use ``PopulationTripsParameters`` to change the parameters.
Use ``Parameters`` to change the model configuration.

.. automodule:: mobility.choice_models.population_trips_parameters
.. automodule:: mobility.trips.group_day_trips.core.parameters
:members:

``population_trips`` uses different other classes :
# ``StateInitializer``: initialises the data
# ``DestinationSequenceSampler`` samples destinations sequences
# ``TopKModeSequenceSearch`` finds the k best modal chains for each destination sequence
# ``StateUpdater`` updates population state distributions over motive/destination/mode sequence

.. automodule:: mobility.choice_models.state_initializer
:members:

.. automodule:: mobility.choice_models.destination_sequence_sampler
:members:

.. automodule:: mobility.choice_models.top_k_mode_sequence_search
:members:

.. automodule:: mobility.choice_models.state_updater
:members:


----------------
Helpers
----------------
``TopKModeSequenceSearch`` uses the function ``add_index`` to ensure a stable integer index exists for a categorical or string column.

``GroupDayTrips`` produces results through ``RunResults`` and stores
transition events that can be analyzed with the evaluation helpers.

.. automodule:: mobility.choice_models.add_index
.. automodule:: mobility.trips.group_day_trips.core.results
:members:


----------------
Trips
IndividualYearTrips
----------------

Besides population_trips, trips can be sampled using the class ``Trips``. Use the .get() method to access a dataframe with those trips.
Individual trips can be sampled using the class ``IndividualYearTrips``.
Use ``.get()`` to access the generated dataframe.

.. automodule:: mobility.trips
.. automodule:: mobility.trips.individual_year_trips
:members:

The trip generation uses the ``safe_sample`` module to ensure we do not use non-representative data
(from a group below the minimal sample size).

.. automodule:: mobility.safe_sample
.. automodule:: mobility.trips.individual_year_trips.safe_sample
:members:
4 changes: 2 additions & 2 deletions examples/old_examples/Hauts-Doubs/radiation-JU-NE-25-39.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mobility.radiation_departments import run_model_for_territory
from mobility.radiation_FR_CH import get_franco_swiss_data_for_model
from mobility.runtime.r_integrationadiation_departments import run_model_for_territory
from mobility.runtime.r_integrationadiation_FR_CH import get_franco_swiss_data_for_model

terr = ["25", "39", "NE", "VD"]
# terr =["25","39"]
Expand Down
2 changes: 1 addition & 1 deletion examples/old_examples/Millau/Millau_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(communes_surfaces_csv)
"""

from mobility.radiation_departments import *
from mobility.runtime.r_integrationadiation_departments import *
import time


Expand Down
2 changes: 1 addition & 1 deletion examples/old_examples/Millau/pa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mobility.radiation_departments import *
from mobility.runtime.r_integrationadiation_departments import *

dep =["64"]

Expand Down
4 changes: 2 additions & 2 deletions examples/old_examples/mobility_survey/mobility_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import dotenv
import mobility

from mobility.parsers import MobilitySurvey
from mobility.surveys import MobilitySurvey

dotenv.load_dotenv()

Expand All @@ -12,4 +12,4 @@
)

ms_2019 = MobilitySurvey(source="EMP-2019")
ms_2008 = MobilitySurvey(source="ENTD-2008")
ms_2008 = MobilitySurvey(source="ENTD-2008")
Loading
Loading