PyTDLM 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. pytdlm-0.2.0/.github/workflows/publish.yml +35 -0
  2. {pytdlm-0.1.0 → pytdlm-0.2.0}/.github/workflows/test-builds.yml +44 -38
  3. {pytdlm-0.1.0 → pytdlm-0.2.0}/.github/workflows/test-examples.yml +4 -4
  4. {pytdlm-0.1.0 → pytdlm-0.2.0}/.gitignore +5 -0
  5. {pytdlm-0.1.0 → pytdlm-0.2.0}/PKG-INFO +42 -35
  6. {pytdlm-0.1.0 → pytdlm-0.2.0}/PyTDLM.egg-info/PKG-INFO +42 -35
  7. {pytdlm-0.1.0 → pytdlm-0.2.0}/PyTDLM.egg-info/SOURCES.txt +11 -4
  8. {pytdlm-0.1.0 → pytdlm-0.2.0}/PyTDLM.egg-info/requires.txt +1 -0
  9. pytdlm-0.2.0/README.md +108 -0
  10. pytdlm-0.2.0/TDLM/__init__.py +29 -0
  11. pytdlm-0.2.0/TDLM/tdlm.py +1890 -0
  12. pytdlm-0.2.0/docs/assets/logo.png +0 -0
  13. pytdlm-0.2.0/docs/index.md +67 -0
  14. pytdlm-0.2.0/docs/news.md +18 -0
  15. pytdlm-0.2.0/docs/reference.md +1 -0
  16. pytdlm-0.2.0/docs/start.md +45 -0
  17. pytdlm-0.2.0/docs/tutorial.md +8 -0
  18. {pytdlm-0.1.0 → pytdlm-0.2.0}/environment.yml +1 -0
  19. pytdlm-0.2.0/examples/basic_usage.py +209 -0
  20. {pytdlm-0.1.0 → pytdlm-0.2.0}/meta.yaml +1 -0
  21. pytdlm-0.2.0/mkdocs.yml +66 -0
  22. {pytdlm-0.1.0 → pytdlm-0.2.0}/pyproject.toml +4 -2
  23. pytdlm-0.2.0/tests/test_tdlm.py +632 -0
  24. pytdlm-0.1.0/.github/workflows/publish.yml +0 -120
  25. pytdlm-0.1.0/README.md +0 -102
  26. pytdlm-0.1.0/TDLM/__init__.py +0 -24
  27. pytdlm-0.1.0/TDLM/tdlm.py +0 -821
  28. pytdlm-0.1.0/docs/examples/basic_usage.py +0 -181
  29. pytdlm-0.1.0/tests/test_tdlm.py +0 -217
  30. {pytdlm-0.1.0 → pytdlm-0.2.0}/LICENSE +0 -0
  31. {pytdlm-0.1.0 → pytdlm-0.2.0}/MANIFEST.in +0 -0
  32. {pytdlm-0.1.0 → pytdlm-0.2.0}/PyTDLM.egg-info/dependency_links.txt +0 -0
  33. {pytdlm-0.1.0 → pytdlm-0.2.0}/PyTDLM.egg-info/top_level.txt +0 -0
  34. {pytdlm-0.1.0/docs → pytdlm-0.2.0}/examples/data_US/Distance.csv.gz +0 -0
  35. {pytdlm-0.1.0/docs → pytdlm-0.2.0}/examples/data_US/Inputs.csv +0 -0
  36. {pytdlm-0.1.0/docs → pytdlm-0.2.0}/examples/data_US/OD.csv +0 -0
  37. {pytdlm-0.1.0 → pytdlm-0.2.0}/setup.cfg +0 -0
  38. {pytdlm-0.1.0 → pytdlm-0.2.0}/tests/__init__.py +0 -0
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish-pypi:
9
+ runs-on: ubuntu-latest
10
+ if: github.event_name == 'release'
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: '3.12'
19
+
20
+ - name: Install build dependencies
21
+ run: |
22
+ python -m pip install --upgrade pip
23
+ python -m pip install build twine
24
+
25
+ - name: Build package
26
+ run: python -m build
27
+
28
+ - name: Check package
29
+ run: twine check dist/*
30
+
31
+ - name: Publish to PyPI
32
+ env:
33
+ TWINE_USERNAME: __token__
34
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
35
+ run: twine upload dist/*
@@ -21,7 +21,7 @@ jobs:
21
21
  - uses: actions/checkout@v4
22
22
 
23
23
  - name: Set up Python ${{ matrix.python-version }}
24
- uses: actions/setup-python@v4
24
+ uses: actions/setup-python@v5
25
25
  with:
26
26
  python-version: ${{ matrix.python-version }}
27
27
 
@@ -94,7 +94,7 @@ jobs:
94
94
  # Create a fresh environment and install the package
95
95
  conda create -n test-env python=${{ matrix.python-version }} -y
96
96
  conda activate test-env
97
- conda install -c ./conda-dist tdlm -y
97
+ conda install -c ./conda-dist pytdlm -y
98
98
 
99
99
  - name: Test conda package import
100
100
  shell: bash -l {0}
@@ -117,40 +117,46 @@ jobs:
117
117
  name: conda-dist
118
118
  path: conda-dist/
119
119
 
120
- test-environment-yml:
121
- runs-on: ubuntu-latest
122
- needs: test-conda-build # ensures the conda build job completes before this job runs
123
- steps:
124
- - uses: actions/checkout@v4
125
-
126
- - name: Set up Miniconda
127
- uses: conda-incubator/setup-miniconda@v2
128
- with:
129
- auto-update-conda: true
130
- python-version: 3.9
131
- channels: conda-forge,defaults
132
-
133
- - name: Create environment from environment.yml
134
- shell: bash -l {0}
135
- run: |
136
- conda env create -f environment.yml
137
-
138
- - name: Test environment
139
- shell: bash -l {0}
140
- run: |
141
- conda activate tdlm
142
- python -c "import numpy, pandas, tabulate, tqdm; print('All dependencies imported successfully')"
143
-
144
- # Install the pre-built conda package
145
- PACKAGE_PATH=$(find conda-dist -name "*.tar.bz2" | head -1)
146
- echo "Installing package: $PACKAGE_PATH"
147
- conda install $PACKAGE_PATH -y
148
- python -c "from TDLM import tdlm; print('TDLM imported successfully')"
149
- python -c "import TDLM; print(f'TDLM version: {TDLM.__version__}')"
150
-
151
- - name: Run tests in conda environment
152
- shell: bash -l {0}
153
- run: |
154
- conda activate tdlm
155
- pytest tests/ -v
120
+ # test-environment-yml:
121
+ # runs-on: ubuntu-latest
122
+ # needs: test-conda-build # ensures the conda build job completes before this job runs
123
+ # steps:
124
+ # - uses: actions/checkout@v4
125
+ #
126
+ # - name: Download conda artifact
127
+ # uses: actions/download-artifact@v4
128
+ # with:
129
+ # name: conda-dist
130
+ # path: conda-dist
131
+ #
132
+ # - name: Set up Miniconda
133
+ # uses: conda-incubator/setup-miniconda@v2
134
+ # with:
135
+ # auto-update-conda: true
136
+ # python-version: 3.9
137
+ # channels: conda-forge,defaults
138
+ #
139
+ # - name: Create environment from environment.yml
140
+ # shell: bash -l {0}
141
+ # run: |
142
+ # conda env create -f environment.yml
143
+ #
144
+ # - name: Test environment
145
+ # shell: bash -l {0}
146
+ # run: |
147
+ # conda activate pytdlm
148
+ # python -c "import numpy, pandas, tabulate, tqdm; print('All dependencies imported successfully')"
149
+ #
150
+ # # Install the pre-built conda package
151
+ # PACKAGE_PATH=$(find conda-dist -name "*.tar.bz2" | head -1)
152
+ # echo "Installing package: $PACKAGE_PATH"
153
+ # conda install $PACKAGE_PATH -y
154
+ # python -c "from TDLM import tdlm; print('TDLM imported successfully')"
155
+ # python -c "import TDLM; print(f'TDLM version: {TDLM.__version__}')"
156
+ #
157
+ # - name: Run tests in conda environment
158
+ # shell: bash -l {0}
159
+ # run: |
160
+ # conda activate pytdlm
161
+ # pytest tests/ -v
156
162
 
@@ -13,7 +13,7 @@ jobs:
13
13
  - uses: actions/checkout@v4
14
14
 
15
15
  - name: Set up Python
16
- uses: actions/setup-python@v4
16
+ uses: actions/setup-python@v5
17
17
  with:
18
18
  python-version: '3.9'
19
19
 
@@ -25,7 +25,7 @@ jobs:
25
25
 
26
26
  - name: Test basic usage example with pip
27
27
  run: |
28
- cd docs/examples
28
+ cd examples
29
29
  python basic_usage.py
30
30
 
31
31
  - name: Set up Miniconda for conda test
@@ -46,8 +46,8 @@ jobs:
46
46
  conda build . --output-folder conda-dist
47
47
 
48
48
  # Install the built package
49
- conda install -c ./conda-dist tdlm -y
49
+ conda install -c ./conda-dist pytdlm -y
50
50
 
51
51
  # Test the example
52
- cd docs/examples
52
+ cd examples
53
53
  python basic_usage.py
@@ -83,3 +83,8 @@ dmypy.json
83
83
  # OS
84
84
  .DS_Store
85
85
  Thumbs.db
86
+
87
+ # MkDocs
88
+
89
+ site/
90
+
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTDLM
3
- Version: 0.1.0
4
- Summary: Systematic comparison of trip distribution laws and models
5
- Author-email: Maxime Lenormand <maxime.lenormand@inrae.fr>
3
+ Version: 0.2.0
4
+ Summary: Systematic comparison of trip distribution laws and models in Python
5
+ Maintainer-email: Rémi Perrier <remi.perrier@cnrs.fr>, Maxime Lenormand <maxime.lenormand@inrae.fr>
6
6
  License: GPL-3.0
7
7
  Project-URL: Homepage, https://github.com/RTDLM/PyTDLM
8
8
  Project-URL: Repository, https://github.com/RTDLM/PyTDLM
@@ -24,6 +24,7 @@ Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: numpy>=1.20.0
26
26
  Requires-Dist: pandas>=1.3.0
27
+ Requires-Dist: scipy>=1.8.0
27
28
  Requires-Dist: tabulate>=0.9.0
28
29
  Requires-Dist: tqdm>=4.60.0
29
30
  Provides-Extra: dev
@@ -37,29 +38,38 @@ Requires-Dist: sphinx>=4.0; extra == "docs"
37
38
  Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
38
39
  Dynamic: license-file
39
40
 
40
- # PyTDLM: Systematic comparison of trip distribution laws and models
41
+ # __PyTDLM__ <img src="docs/assets/logo.png" align="right" alt="" width="138" />
41
42
 
42
- A Python port of the [TDLM R package](https://github.com/RTDLM/TDLM), with numpy-based implementations and parallel processing support for multiple exponent values.
43
+ # Systematic comparison of trip distribution laws and models in Python
43
44
 
44
- ## Overview
45
+ <!-- badges: start -->
46
+ [![Test Build and Distribution](https://github.com/RTDLM/PyTDLM/actions/workflows/test-builds.yml/badge.svg)](https://github.com/RTDLM/PyTDLM/actions/workflows/test-builds.yml)
47
+ [![PyPI Version](https://img.shields.io/pypi/v/pytdlm.svg)](https://pypi.org/project/pytdlm)
48
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/pytdlm.svg)](https://pypistats.org/packages/pytdlm)
49
+ [![Conda Version](https://img.shields.io/conda/v/conda-forge/pytdlm.svg)](https://anaconda.org/conda-forge/pytdlm)
50
+ [![Conda Downloads](https://img.shields.io/conda/d/conda-forge/pytdlm)](https://anaconda.org/conda-forge/pytdlm)
45
51
 
46
- PyTDLM provides implementations of several trip distribution models commonly used in transportation planning and spatial analysis:
52
+ <!-- badges: end -->
47
53
 
48
- ### Available Laws
49
- - **GravExp**: Gravity model with exponential distance decay
50
- - **NGravExp**: Normalized gravity model with exponential decay
51
- - **GravPow**: Gravity model with power distance decay
52
- - **NGravPow**: Normalized gravity model with power decay
53
- - **Schneider**: Schneider's intervening opportunities model
54
- - **Rad**: Radiation model
55
- - **RadExt**: Extended radiation model
56
- - **Rand**: Random model (baseline)
54
+ ## Description
57
55
 
58
- ### Available Models
59
- - **UM**: Unconstrained Model
60
- - **PCM**: Production Constrained Model
61
- - **ACM**: Attraction Constrained Model
62
- - **DCM**: Doubly Constrained Model
56
+ The main purpose of these packages is to provide a rigorous framework for
57
+ fairly comparing trip distribution laws and models, as described in
58
+ [Lenormand *et al.* (2016)](https://doi.org/10.1016/j.jtrangeo.2015.12.008).
59
+ This general framework relies on a two-step approach to generate mobility flows,
60
+ separating the trip distribution law, gravity or intervening opportunities, from
61
+ the modeling approach used to derive flows from this law.
62
+
63
+ To make this framework more accessible, we developed both an
64
+ [R package](https://rtdlm.github.io/TDLM/)
65
+ and a [Python package](https://rtdlm.github.io/PyTDLM/), which replace the
66
+ original [Java scripts](https://github.com/maximelenormand/Trip-distribution-laws-and-models)
67
+ and extend their functionality.
68
+
69
+ [PyTDLM](https://rtdlm.github.io/PyTDLM/) is a Python port of the
70
+ [TDLM R package](https://github.com/RTDLM/TDLM), with
71
+ numpy-based implementations and parallel processing support for multiple
72
+ exponent values.
63
73
 
64
74
  ## Installation
65
75
 
@@ -76,11 +86,11 @@ pip install PyTDLM
76
86
  ### From source
77
87
  ```bash
78
88
  git clone https://github.com/PyTDLM/TDLM.git
79
- cd TDLM
89
+ cd PyTDLM
80
90
  pip install -e .
81
91
  ```
82
92
 
83
- ## Quick Start
93
+ ## Quick start
84
94
 
85
95
  ```python
86
96
  import numpy as np
@@ -88,7 +98,7 @@ from TDLM import tdlm
88
98
 
89
99
  # Prepare your data
90
100
  mi = np.array([100, 200, 150]) # Origin masses
91
- mj = np.array([80, 180, 120]) # Destination masses
101
+ mj = np.array([80, 180, 120]) # Destination masses
92
102
  dij = np.array([[0, 10, 15], # Distance matrix
93
103
  [10, 0, 8],
94
104
  [15, 8, 0]])
@@ -121,21 +131,18 @@ print(gof_results[0.1].to_markdown(index=False))
121
131
 
122
132
  ## Documentation
123
133
 
124
- For detailed documentation and examples, visit: [https://rtdlm.github.io/PyTDLM/](https://rtdlm.github.io/PyTDLM/)
125
-
126
- ## License
127
-
128
- This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
134
+ For detailed documentation and examples, visit:
135
+ [https://rtdlm.github.io/PyTDLM/](https://rtdlm.github.io/PyTDLM/)
129
136
 
130
137
  ## Citation
131
138
 
132
- If you use this library in your research, please cite:
139
+ If you use this library in your research, please cite: [Reference to come].
133
140
 
134
141
  ```bibtex
135
- @software{lenormand2024tdlm,
136
- title={TDLM: Trip Distribution Law Models},
137
- author={Lenormand, Maxime},
138
- year={2024},
139
- url={https://github.com/RTDLM/PyTDLM}
142
+ @software{PyTDLM,
143
+ author = {Perrier, R., Gargiulo, G., Jayet, C. and Lenormand, M.},
144
+ title = {PyTDLM: Systematic comparison of trip distribution laws and models in Python},
145
+ year = {2025},
146
+ note = {Reference forthcoming}
140
147
  }
141
148
  ```
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTDLM
3
- Version: 0.1.0
4
- Summary: Systematic comparison of trip distribution laws and models
5
- Author-email: Maxime Lenormand <maxime.lenormand@inrae.fr>
3
+ Version: 0.2.0
4
+ Summary: Systematic comparison of trip distribution laws and models in Python
5
+ Maintainer-email: Rémi Perrier <remi.perrier@cnrs.fr>, Maxime Lenormand <maxime.lenormand@inrae.fr>
6
6
  License: GPL-3.0
7
7
  Project-URL: Homepage, https://github.com/RTDLM/PyTDLM
8
8
  Project-URL: Repository, https://github.com/RTDLM/PyTDLM
@@ -24,6 +24,7 @@ Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: numpy>=1.20.0
26
26
  Requires-Dist: pandas>=1.3.0
27
+ Requires-Dist: scipy>=1.8.0
27
28
  Requires-Dist: tabulate>=0.9.0
28
29
  Requires-Dist: tqdm>=4.60.0
29
30
  Provides-Extra: dev
@@ -37,29 +38,38 @@ Requires-Dist: sphinx>=4.0; extra == "docs"
37
38
  Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
38
39
  Dynamic: license-file
39
40
 
40
- # PyTDLM: Systematic comparison of trip distribution laws and models
41
+ # __PyTDLM__ <img src="docs/assets/logo.png" align="right" alt="" width="138" />
41
42
 
42
- A Python port of the [TDLM R package](https://github.com/RTDLM/TDLM), with numpy-based implementations and parallel processing support for multiple exponent values.
43
+ # Systematic comparison of trip distribution laws and models in Python
43
44
 
44
- ## Overview
45
+ <!-- badges: start -->
46
+ [![Test Build and Distribution](https://github.com/RTDLM/PyTDLM/actions/workflows/test-builds.yml/badge.svg)](https://github.com/RTDLM/PyTDLM/actions/workflows/test-builds.yml)
47
+ [![PyPI Version](https://img.shields.io/pypi/v/pytdlm.svg)](https://pypi.org/project/pytdlm)
48
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/pytdlm.svg)](https://pypistats.org/packages/pytdlm)
49
+ [![Conda Version](https://img.shields.io/conda/v/conda-forge/pytdlm.svg)](https://anaconda.org/conda-forge/pytdlm)
50
+ [![Conda Downloads](https://img.shields.io/conda/d/conda-forge/pytdlm)](https://anaconda.org/conda-forge/pytdlm)
45
51
 
46
- PyTDLM provides implementations of several trip distribution models commonly used in transportation planning and spatial analysis:
52
+ <!-- badges: end -->
47
53
 
48
- ### Available Laws
49
- - **GravExp**: Gravity model with exponential distance decay
50
- - **NGravExp**: Normalized gravity model with exponential decay
51
- - **GravPow**: Gravity model with power distance decay
52
- - **NGravPow**: Normalized gravity model with power decay
53
- - **Schneider**: Schneider's intervening opportunities model
54
- - **Rad**: Radiation model
55
- - **RadExt**: Extended radiation model
56
- - **Rand**: Random model (baseline)
54
+ ## Description
57
55
 
58
- ### Available Models
59
- - **UM**: Unconstrained Model
60
- - **PCM**: Production Constrained Model
61
- - **ACM**: Attraction Constrained Model
62
- - **DCM**: Doubly Constrained Model
56
+ The main purpose of these packages is to provide a rigorous framework for
57
+ fairly comparing trip distribution laws and models, as described in
58
+ [Lenormand *et al.* (2016)](https://doi.org/10.1016/j.jtrangeo.2015.12.008).
59
+ This general framework relies on a two-step approach to generate mobility flows,
60
+ separating the trip distribution law, gravity or intervening opportunities, from
61
+ the modeling approach used to derive flows from this law.
62
+
63
+ To make this framework more accessible, we developed both an
64
+ [R package](https://rtdlm.github.io/TDLM/)
65
+ and a [Python package](https://rtdlm.github.io/PyTDLM/), which replace the
66
+ original [Java scripts](https://github.com/maximelenormand/Trip-distribution-laws-and-models)
67
+ and extend their functionality.
68
+
69
+ [PyTDLM](https://rtdlm.github.io/PyTDLM/) is a Python port of the
70
+ [TDLM R package](https://github.com/RTDLM/TDLM), with
71
+ numpy-based implementations and parallel processing support for multiple
72
+ exponent values.
63
73
 
64
74
  ## Installation
65
75
 
@@ -76,11 +86,11 @@ pip install PyTDLM
76
86
  ### From source
77
87
  ```bash
78
88
  git clone https://github.com/PyTDLM/TDLM.git
79
- cd TDLM
89
+ cd PyTDLM
80
90
  pip install -e .
81
91
  ```
82
92
 
83
- ## Quick Start
93
+ ## Quick start
84
94
 
85
95
  ```python
86
96
  import numpy as np
@@ -88,7 +98,7 @@ from TDLM import tdlm
88
98
 
89
99
  # Prepare your data
90
100
  mi = np.array([100, 200, 150]) # Origin masses
91
- mj = np.array([80, 180, 120]) # Destination masses
101
+ mj = np.array([80, 180, 120]) # Destination masses
92
102
  dij = np.array([[0, 10, 15], # Distance matrix
93
103
  [10, 0, 8],
94
104
  [15, 8, 0]])
@@ -121,21 +131,18 @@ print(gof_results[0.1].to_markdown(index=False))
121
131
 
122
132
  ## Documentation
123
133
 
124
- For detailed documentation and examples, visit: [https://rtdlm.github.io/PyTDLM/](https://rtdlm.github.io/PyTDLM/)
125
-
126
- ## License
127
-
128
- This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
134
+ For detailed documentation and examples, visit:
135
+ [https://rtdlm.github.io/PyTDLM/](https://rtdlm.github.io/PyTDLM/)
129
136
 
130
137
  ## Citation
131
138
 
132
- If you use this library in your research, please cite:
139
+ If you use this library in your research, please cite: [Reference to come].
133
140
 
134
141
  ```bibtex
135
- @software{lenormand2024tdlm,
136
- title={TDLM: Trip Distribution Law Models},
137
- author={Lenormand, Maxime},
138
- year={2024},
139
- url={https://github.com/RTDLM/PyTDLM}
142
+ @software{PyTDLM,
143
+ author = {Perrier, R., Gargiulo, G., Jayet, C. and Lenormand, M.},
144
+ title = {PyTDLM: Systematic comparison of trip distribution laws and models in Python},
145
+ year = {2025},
146
+ note = {Reference forthcoming}
140
147
  }
141
148
  ```
@@ -4,6 +4,7 @@ MANIFEST.in
4
4
  README.md
5
5
  environment.yml
6
6
  meta.yaml
7
+ mkdocs.yml
7
8
  pyproject.toml
8
9
  .github/workflows/publish.yml
9
10
  .github/workflows/test-builds.yml
@@ -15,9 +16,15 @@ PyTDLM.egg-info/requires.txt
15
16
  PyTDLM.egg-info/top_level.txt
16
17
  TDLM/__init__.py
17
18
  TDLM/tdlm.py
18
- docs/examples/basic_usage.py
19
- docs/examples/data_US/Distance.csv.gz
20
- docs/examples/data_US/Inputs.csv
21
- docs/examples/data_US/OD.csv
19
+ docs/index.md
20
+ docs/news.md
21
+ docs/reference.md
22
+ docs/start.md
23
+ docs/tutorial.md
24
+ docs/assets/logo.png
25
+ examples/basic_usage.py
26
+ examples/data_US/Distance.csv.gz
27
+ examples/data_US/Inputs.csv
28
+ examples/data_US/OD.csv
22
29
  tests/__init__.py
23
30
  tests/test_tdlm.py
@@ -1,5 +1,6 @@
1
1
  numpy>=1.20.0
2
2
  pandas>=1.3.0
3
+ scipy>=1.8.0
3
4
  tabulate>=0.9.0
4
5
  tqdm>=4.60.0
5
6
 
pytdlm-0.2.0/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # __PyTDLM__ <img src="docs/assets/logo.png" align="right" alt="" width="138" />
2
+
3
+ # Systematic comparison of trip distribution laws and models in Python
4
+
5
+ <!-- badges: start -->
6
+ [![Test Build and Distribution](https://github.com/RTDLM/PyTDLM/actions/workflows/test-builds.yml/badge.svg)](https://github.com/RTDLM/PyTDLM/actions/workflows/test-builds.yml)
7
+ [![PyPI Version](https://img.shields.io/pypi/v/pytdlm.svg)](https://pypi.org/project/pytdlm)
8
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/pytdlm.svg)](https://pypistats.org/packages/pytdlm)
9
+ [![Conda Version](https://img.shields.io/conda/v/conda-forge/pytdlm.svg)](https://anaconda.org/conda-forge/pytdlm)
10
+ [![Conda Downloads](https://img.shields.io/conda/d/conda-forge/pytdlm)](https://anaconda.org/conda-forge/pytdlm)
11
+
12
+ <!-- badges: end -->
13
+
14
+ ## Description
15
+
16
+ The main purpose of these packages is to provide a rigorous framework for
17
+ fairly comparing trip distribution laws and models, as described in
18
+ [Lenormand *et al.* (2016)](https://doi.org/10.1016/j.jtrangeo.2015.12.008).
19
+ This general framework relies on a two-step approach to generate mobility flows,
20
+ separating the trip distribution law, gravity or intervening opportunities, from
21
+ the modeling approach used to derive flows from this law.
22
+
23
+ To make this framework more accessible, we developed both an
24
+ [R package](https://rtdlm.github.io/TDLM/)
25
+ and a [Python package](https://rtdlm.github.io/PyTDLM/), which replace the
26
+ original [Java scripts](https://github.com/maximelenormand/Trip-distribution-laws-and-models)
27
+ and extend their functionality.
28
+
29
+ [PyTDLM](https://rtdlm.github.io/PyTDLM/) is a Python port of the
30
+ [TDLM R package](https://github.com/RTDLM/TDLM), with
31
+ numpy-based implementations and parallel processing support for multiple
32
+ exponent values.
33
+
34
+ ## Installation
35
+
36
+ ### Using conda
37
+ ```bash
38
+ conda install -c conda-forge pytdlm
39
+ ```
40
+
41
+ ### Using pip
42
+ ```bash
43
+ pip install PyTDLM
44
+ ```
45
+
46
+ ### From source
47
+ ```bash
48
+ git clone https://github.com/PyTDLM/TDLM.git
49
+ cd PyTDLM
50
+ pip install -e .
51
+ ```
52
+
53
+ ## Quick start
54
+
55
+ ```python
56
+ import numpy as np
57
+ from TDLM import tdlm
58
+
59
+ # Prepare your data
60
+ mi = np.array([100, 200, 150]) # Origin masses
61
+ mj = np.array([80, 180, 120]) # Destination masses
62
+ dij = np.array([[0, 10, 15], # Distance matrix
63
+ [10, 0, 8],
64
+ [15, 8, 0]])
65
+ Oi = np.array([50, 80, 60]) # Out-trips
66
+ Dj = np.array([40, 90, 50]) # In-trips
67
+ Tij_observed = np.array([[0, 25, 25], # Observed trip matrix
68
+ [30, 0, 50],
69
+ [35, 35, 0]])
70
+
71
+ # Run simulation
72
+ exponent = np.arange(0.1, 1.01, 0.01)
73
+ results = tdlm.run_law_model(
74
+ law='NGravExp',
75
+ mass_origin=mi,
76
+ mass_destination=mj,
77
+ distance=dij,
78
+ exponent=exponent,
79
+ model='DCM',
80
+ out_trips=Oi,
81
+ in_trips=Dj,
82
+ repli=100
83
+ )
84
+
85
+ # Calculate goodness-of-fit
86
+ gof_results = tdlm.gof(sim=results, obs=Tij_observed, distance=dij)
87
+
88
+ # Print results for a given exponent
89
+ print(gof_results[0.1].to_markdown(index=False))
90
+ ```
91
+
92
+ ## Documentation
93
+
94
+ For detailed documentation and examples, visit:
95
+ [https://rtdlm.github.io/PyTDLM/](https://rtdlm.github.io/PyTDLM/)
96
+
97
+ ## Citation
98
+
99
+ If you use this library in your research, please cite: [Reference to come].
100
+
101
+ ```bibtex
102
+ @software{PyTDLM,
103
+ author = {Perrier, R., Gargiulo, G., Jayet, C. and Lenormand, M.},
104
+ title = {PyTDLM: Systematic comparison of trip distribution laws and models in Python},
105
+ year = {2025},
106
+ note = {Reference forthcoming}
107
+ }
108
+ ```
@@ -0,0 +1,29 @@
1
+ """
2
+ TDLM: Systematic comparison of trip distribution laws and models in Python
3
+
4
+ A Python port of the TDLM R package, with
5
+ numpy-based implementations and parallel processing support for multiple
6
+ exponent values.
7
+
8
+ Author: Rémi Perrier (2025)
9
+ """
10
+
11
+ from . import tdlm as tdlm
12
+ from .tdlm import extract_opportunities, run_optimization, run_law_model_gof, run_law_model, run_law, run_model, gof, _TDLMError
13
+
14
+ __version__ = "0.2.0"
15
+ __author__ = "Rémi Perrier"
16
+ __email__ = "remi.perrier@cnrs.fr"
17
+ __license__ = "GPL-3.0"
18
+
19
+ __all__ = [
20
+ "tdlm",
21
+ "extract_opportunities",
22
+ "run_optimization",
23
+ "run_law_model_gof",
24
+ "run_law_model",
25
+ "run_law",
26
+ "run_model",
27
+ "gof",
28
+ "_TDLMError"
29
+ ]