PyTDLM 
Systematic comparison of trip distribution laws and models in Python
Description
The main purpose of these packages is to provide a rigorous framework for fairly comparing trip distribution laws and models, as described in Lenormand et al. (2016). This general framework relies on a two-step approach to generate mobility flows, separating the trip distribution law, gravity or intervening opportunities, from the modeling approach used to derive flows from this law.
To make this framework more accessible, we developed both an R package and a Python package, which replace the original Java scripts and extend their functionality.
PyTDLM is a Python port of the TDLM R package, with numpy-based implementations and parallel processing support for multiple exponent values.
Installation
Using conda
conda install -c conda-forge pytdlm
Using pip
pip install PyTDLM
From source
git clone https://github.com/PyTDLM/TDLM.git
cd PyTDLM
pip install -e .
Quick start
import numpy as np
from TDLM import tdlm
# Prepare your data
mi = np.array([100, 200, 150]) # Origin masses
mj = np.array([80, 180, 120]) # Destination masses
dij = np.array([[0, 10, 15], # Distance matrix
[10, 0, 8],
[15, 8, 0]])
Oi = np.array([50, 80, 60]) # Out-trips
Dj = np.array([40, 90, 50]) # In-trips
Tij_observed = np.array([[0, 25, 25], # Observed trip matrix
[30, 0, 50],
[35, 35, 0]])
# Run simulation
exponent = np.arange(0.1, 1.01, 0.01)
results = tdlm.run_law_model(
law='NGravExp',
mass_origin=mi,
mass_destination=mj,
distance=dij,
exponent=exponent,
model='DCM',
out_trips=Oi,
in_trips=Dj,
repli=100
)
# Calculate goodness-of-fit
gof_results = tdlm.gof(sim=results, obs=Tij_observed, distance=dij)
# Print results for a given exponent
print(gof_results[0.1].to_markdown(index=False))
Documentation
For detailed documentation and examples, visit: https://rtdlm.github.io/PyTDLM/
Citation
If you use this library in your research, please cite: [Reference to come].
@software{PyTDLM,
author = {Perrier, R., Gargiulo, G., Jayet, C. and Lenormand, M.},
title = {PyTDLM: Systematic comparison of trip distribution laws and models in Python},
year = {2025},
note = {Reference forthcoming}
}
Metadata
Release files for PyTDLM 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytdlm-0.2.2.tar.gz | 80.6 MB | Without provenance | Details for pytdlm-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytdlm-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for pytdlm-0.2.2-py3-none-any.whl |
Total release size: 80.7 MB
Release files / pytdlm-0.2.2.tar.gz
| Download URL | pytdlm-0.2.2.tar.gz |
|---|---|
| Size | 80.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c47019d135e107ce9cbe4085c9854a70e48bde66905876328b6f3bce0b92f93d
|
|
BLAKE2b-256 checksum How to use checksums |
4e60a9e178357d7ecdf5bb57d0ee55a655fded719e2e2be14dd1e577426cc8ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / pytdlm-0.2.2-py3-none-any.whl
| Download URL | pytdlm-0.2.2-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
185eb41c8d2911bff070d56cd70bcc4b9331d47ec0172023fa3d4c8444b2deae
|
|
BLAKE2b-256 checksum How to use checksums |
c8e44e2260b05e5f3a8acfd009d109f837e9fce008fdad965a23c18c5d121e06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for PyTDLM 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.