econcomplex 1.0.0__tar.gz → 1.1.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.
- {econcomplex-1.0.0 → econcomplex-1.1.0}/CHANGELOG.md +64 -0
- {econcomplex-1.0.0/econcomplex.egg-info → econcomplex-1.1.0}/PKG-INFO +13 -12
- {econcomplex-1.0.0 → econcomplex-1.1.0}/README.md +9 -9
- {econcomplex-1.0.0 → econcomplex-1.1.0}/README.pt-BR.md +9 -9
- {econcomplex-1.0.0 → econcomplex-1.1.0}/docs/api_reference_en.tex +10 -7
- {econcomplex-1.0.0 → econcomplex-1.1.0}/docs/api_reference_pt.tex +10 -7
- econcomplex-1.1.0/docs/econcomplex_documentation_en.pdf +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/docs/econcomplex_documentation_en.tex +47 -14
- econcomplex-1.1.0/docs/econcomplex_documentation_pt.pdf +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/docs/econcomplex_documentation_pt.tex +44 -12
- {econcomplex-1.0.0 → econcomplex-1.1.0}/docs/generate_api_reference.py +2 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/__init__.py +15 -9
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/complexity/eci_pci.py +14 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/complexity/subnational.py +28 -11
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/core/diversity.py +9 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/core/preprocess.py +13 -1
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/core/rca.py +11 -5
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/core/utils.py +84 -3
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/dynamics/entry_exit.py +4 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/inequality/concentration.py +3 -2
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/inequality/gini.py +3 -2
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/optimization/diffusion.py +6 -4
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/optimization/portfolio.py +61 -25
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/optimization/steppingstone.py +3 -2
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/outlook/coi_cog.py +19 -4
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/patents/recombination.py +5 -2
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/pipeline.py +45 -9
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/productivity/prody.py +7 -14
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/relatedness/cross_space.py +11 -1
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/relatedness/density.py +26 -8
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/relatedness/proximity.py +49 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0/econcomplex.egg-info}/PKG-INFO +13 -12
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex.egg-info/SOURCES.txt +2 -1
- {econcomplex-1.0.0 → econcomplex-1.1.0}/pyproject.toml +6 -4
- {econcomplex-1.0.0 → econcomplex-1.1.0}/tests/test_core.py +43 -0
- econcomplex-1.1.0/tests/test_quality.py +336 -0
- econcomplex-1.0.0/docs/econcomplex_documentation_en.pdf +0 -0
- econcomplex-1.0.0/docs/econcomplex_documentation_pt.pdf +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/LICENSE +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/MANIFEST.in +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/complexity/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/complexity/eigenvector.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/complexity/fitness.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/complexity/reflections.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/core/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/dynamics/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/dynamics/growth.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/inequality/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/optimization/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/optimization/growth_target.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/outlook/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/patents/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/productivity/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/relatedness/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/relatedness/cooccurrence.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/specialization/__init__.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/specialization/location_quotient.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex/specialization/similarity.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex.egg-info/dependency_links.txt +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex.egg-info/requires.txt +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/econcomplex.egg-info/top_level.txt +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/examples/basic_usage.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/examples/eci_optimization.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/setup.cfg +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/setup.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/tests/test_diffusion.py +0 -0
- {econcomplex-1.0.0 → econcomplex-1.1.0}/tests/test_optimization.py +0 -0
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.0] — 2026-11-24
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Label alignment.** Auxiliary inputs given as labelled pandas objects are
|
|
7
|
+
now matched to the matrix by label instead of by position. Before, a
|
|
8
|
+
`Series` or `DataFrame` with the same labels in a different order silently
|
|
9
|
+
produced wrong results. Affects `prody`, `expy`, `pgi`, `peii`, `rpop`,
|
|
10
|
+
`hoover_index`, `hoover_gini`, `coi`, `cog`, every density function (`phi`),
|
|
11
|
+
`cross_relatedness` (`x_phi`), `subnational_eci`, `modular_complexity`
|
|
12
|
+
(`eor`) and the strategic-diffusion functions (`active`). Lists, arrays and
|
|
13
|
+
Series with a default integer index are still taken positionally; a missing
|
|
14
|
+
label raises a `ValueError` naming it.
|
|
15
|
+
- **Input validation.** Matrices with NaN/infinite or negative cells now raise
|
|
16
|
+
a clear `ValueError` at the entry point. NaN used to surface as a misleading
|
|
17
|
+
"trimming to the (1, 1)-core" error and negative values were accepted.
|
|
18
|
+
- **`eci_optimization` no longer stalls.** The exact solver could run
|
|
19
|
+
indefinitely on locations with many near-equivalent candidates. It is now
|
|
20
|
+
capped by `time_limit` (default 5 s per location); when the cap is hit the
|
|
21
|
+
best feasible portfolio found is returned, never worse than the greedy one.
|
|
22
|
+
- `subnational_eci` returns NaN (it returned 0) for regions with no
|
|
23
|
+
specialization, and accepts an external PCI in any order, with extra
|
|
24
|
+
activities, or missing some of the matrix's activities.
|
|
25
|
+
- Citations: Catalán, Navarrete & Figueroa (2022) for the cross-space, and
|
|
26
|
+
Pinheiro et al. (2022) for relative relatedness.
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- `product_proximity` and `location_proximity`: return the proximity matrix
|
|
30
|
+
directly instead of the `{"product": ..., "location": ...}` dictionary.
|
|
31
|
+
- `percent` option in `relatedness_density` and its internal/external
|
|
32
|
+
variants: `percent=False` returns shares (0-1), the scale of `distance`
|
|
33
|
+
and `cross_relatedness`. The default (0-100) is unchanged.
|
|
34
|
+
- `exits`, the preferred name for `exit` (which shadows the Python builtin).
|
|
35
|
+
- Runnable `Examples` in the docstrings of the main entry points, executed
|
|
36
|
+
by the test suite (`pytest --doctest-modules`).
|
|
37
|
+
- Continuous integration (GitHub Actions): Python 3.10 to 3.14 and NumPy 1.x.
|
|
38
|
+
- `eci_optimization` output has an `optimal` column (True when the solver
|
|
39
|
+
proved optimality) and warns once when locations reach the time limit.
|
|
40
|
+
- Known-answer tests for the 25 public functions that had no direct test,
|
|
41
|
+
plus a regression test that reproduces the 1.0.1 results to 1e-7.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- Minimum Python is now 3.10. Python 3.9 reached end of life in October 2025
|
|
45
|
+
and is no longer available on the CI runners; `pip` on 3.9 keeps
|
|
46
|
+
installing 1.0.1.
|
|
47
|
+
|
|
48
|
+
### Note
|
|
49
|
+
- The 1.0.1 entry below says outputs were "byte-for-byte identical" to 1.0.0;
|
|
50
|
+
the check actually used a tolerance of 1e-9.
|
|
51
|
+
|
|
52
|
+
## [1.0.1] — 2026-06-13
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
- `compute_complexity` is now a **pure orchestration layer**: it calls the
|
|
56
|
+
same public functions a user would call by hand (`diversity`, `ubiquity`,
|
|
57
|
+
and `distance` are now delegated instead of recomputed inline), so any
|
|
58
|
+
change to an indicator propagates automatically. Outputs are byte-for-byte
|
|
59
|
+
identical to 1.0.0 (verified against a saved baseline for all three methods).
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
- `compute_complexity` now exposes `trim`, `dmin`, and `umin`, forwarded to
|
|
63
|
+
`eci_pci` — the well-connected `(2, 2)` core (recommended for sparse
|
|
64
|
+
subnational data) is finally reachable from the high-level pipeline, not
|
|
65
|
+
only from the matrix-level API.
|
|
66
|
+
|
|
3
67
|
## [1.0.0] — 2026-06-12
|
|
4
68
|
|
|
5
69
|
First official release.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: econcomplex
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Python library for economic complexity and regional science indicators
|
|
5
5
|
Author: Elton Freitas
|
|
6
6
|
License-Expression: MIT
|
|
@@ -13,12 +13,13 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
21
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
21
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.10
|
|
22
23
|
Description-Content-Type: text/markdown
|
|
23
24
|
License-File: LICENSE
|
|
24
25
|
Requires-Dist: numpy>=1.21
|
|
@@ -37,10 +38,10 @@ Dynamic: license-file
|
|
|
37
38
|
|
|
38
39
|
# econcomplex
|
|
39
40
|
|
|
40
|
-
[](CHANGELOG.md)
|
|
42
|
+
[](pyproject.toml)
|
|
42
43
|
[](LICENSE)
|
|
43
|
-
[](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml)
|
|
44
45
|
|
|
45
46
|
**econcomplex** is a Python library for **economic complexity and regional
|
|
46
47
|
science indicators**. It consolidates, in a single coherent API, the tools
|
|
@@ -68,7 +69,7 @@ diffusion) that, to our knowledge, is not available in any other package.
|
|
|
68
69
|
| **ECI Optimization** | Stepping-stone forecast model, entry-effort matrix, exact 0–1 program for minimal-effort diversification portfolios, growth targeting (Stojkoski & Hidalgo 2026) |
|
|
69
70
|
| **Strategic diffusion** | Complex-contagion calibration, five diversification strategies, optimal entry sequencing (Alshamsi, Pinheiro & Hidalgo 2018) |
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
90 public functions in total — the PDF documentation carries a complete API
|
|
72
73
|
reference and an interpretation guide for every indicator family.
|
|
73
74
|
|
|
74
75
|
## Installation
|
|
@@ -83,14 +84,14 @@ Or, for the latest development version straight from GitHub:
|
|
|
83
84
|
pip install git+https://github.com/eltonfreitas/econcomplex.git
|
|
84
85
|
```
|
|
85
86
|
|
|
86
|
-
Requires Python ≥ 3.
|
|
87
|
+
Requires Python ≥ 3.10 with `numpy ≥ 1.21` (1.x **and** 2.x supported),
|
|
87
88
|
`pandas ≥ 1.3`, `scipy ≥ 1.9`. For local development:
|
|
88
89
|
|
|
89
90
|
```bash
|
|
90
91
|
git clone https://github.com/eltonfreitas/econcomplex.git
|
|
91
92
|
cd econcomplex
|
|
92
93
|
pip install -e .[dev]
|
|
93
|
-
pytest #
|
|
94
|
+
pytest # tests + docstring examples
|
|
94
95
|
```
|
|
95
96
|
|
|
96
97
|
## Quick start
|
|
@@ -120,7 +121,7 @@ mat = ec.pivot_to_matrix(df, "region", "sector", "employment")
|
|
|
120
121
|
eci, pci = ec.eci_pci(mat) # eigenvector method (default)
|
|
121
122
|
eci2, pci2 = ec.eci_pci(mat, method="fitness") # same call, other method
|
|
122
123
|
|
|
123
|
-
phi = ec.
|
|
124
|
+
phi = ec.product_proximity(mat) # product space
|
|
124
125
|
density = ec.density(mat, phi=phi) # 0–100 % relatedness density
|
|
125
126
|
coi = ec.coi(mat, pci, phi=phi) # diversification potential
|
|
126
127
|
```
|
|
@@ -192,7 +193,7 @@ bound to the same objects (`density`, `hhi`, `coi`, `pgi`, …).
|
|
|
192
193
|
|
|
193
194
|
## Validation
|
|
194
195
|
|
|
195
|
-
The
|
|
196
|
+
The test suite includes exact validations against the literature: the
|
|
196
197
|
eigenvector ECI/PCI uses the proper non-symmetric solver; the strategic
|
|
197
198
|
diffusion module reproduces the closed-form solution of Alshamsi et al.
|
|
198
199
|
(2018, eq. 2) on the wheel network; relative relatedness follows Pinheiro
|
|
@@ -207,7 +208,7 @@ library recovers the canonical ECI country ranking.
|
|
|
207
208
|
author = {Freitas, Elton},
|
|
208
209
|
title = {econcomplex: economic complexity and regional science indicators in Python},
|
|
209
210
|
year = {2026},
|
|
210
|
-
version = {1.
|
|
211
|
+
version = {1.1.0},
|
|
211
212
|
url = {https://github.com/eltonfreitas/econcomplex}
|
|
212
213
|
}
|
|
213
214
|
```
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# econcomplex
|
|
2
2
|
|
|
3
|
-
[](CHANGELOG.md)
|
|
4
|
+
[](pyproject.toml)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml)
|
|
7
7
|
|
|
8
8
|
**econcomplex** is a Python library for **economic complexity and regional
|
|
9
9
|
science indicators**. It consolidates, in a single coherent API, the tools
|
|
@@ -31,7 +31,7 @@ diffusion) that, to our knowledge, is not available in any other package.
|
|
|
31
31
|
| **ECI Optimization** | Stepping-stone forecast model, entry-effort matrix, exact 0–1 program for minimal-effort diversification portfolios, growth targeting (Stojkoski & Hidalgo 2026) |
|
|
32
32
|
| **Strategic diffusion** | Complex-contagion calibration, five diversification strategies, optimal entry sequencing (Alshamsi, Pinheiro & Hidalgo 2018) |
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
90 public functions in total — the PDF documentation carries a complete API
|
|
35
35
|
reference and an interpretation guide for every indicator family.
|
|
36
36
|
|
|
37
37
|
## Installation
|
|
@@ -46,14 +46,14 @@ Or, for the latest development version straight from GitHub:
|
|
|
46
46
|
pip install git+https://github.com/eltonfreitas/econcomplex.git
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Requires Python ≥ 3.
|
|
49
|
+
Requires Python ≥ 3.10 with `numpy ≥ 1.21` (1.x **and** 2.x supported),
|
|
50
50
|
`pandas ≥ 1.3`, `scipy ≥ 1.9`. For local development:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
53
|
git clone https://github.com/eltonfreitas/econcomplex.git
|
|
54
54
|
cd econcomplex
|
|
55
55
|
pip install -e .[dev]
|
|
56
|
-
pytest #
|
|
56
|
+
pytest # tests + docstring examples
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
## Quick start
|
|
@@ -83,7 +83,7 @@ mat = ec.pivot_to_matrix(df, "region", "sector", "employment")
|
|
|
83
83
|
eci, pci = ec.eci_pci(mat) # eigenvector method (default)
|
|
84
84
|
eci2, pci2 = ec.eci_pci(mat, method="fitness") # same call, other method
|
|
85
85
|
|
|
86
|
-
phi = ec.
|
|
86
|
+
phi = ec.product_proximity(mat) # product space
|
|
87
87
|
density = ec.density(mat, phi=phi) # 0–100 % relatedness density
|
|
88
88
|
coi = ec.coi(mat, pci, phi=phi) # diversification potential
|
|
89
89
|
```
|
|
@@ -155,7 +155,7 @@ bound to the same objects (`density`, `hhi`, `coi`, `pgi`, …).
|
|
|
155
155
|
|
|
156
156
|
## Validation
|
|
157
157
|
|
|
158
|
-
The
|
|
158
|
+
The test suite includes exact validations against the literature: the
|
|
159
159
|
eigenvector ECI/PCI uses the proper non-symmetric solver; the strategic
|
|
160
160
|
diffusion module reproduces the closed-form solution of Alshamsi et al.
|
|
161
161
|
(2018, eq. 2) on the wheel network; relative relatedness follows Pinheiro
|
|
@@ -170,7 +170,7 @@ library recovers the canonical ECI country ranking.
|
|
|
170
170
|
author = {Freitas, Elton},
|
|
171
171
|
title = {econcomplex: economic complexity and regional science indicators in Python},
|
|
172
172
|
year = {2026},
|
|
173
|
-
version = {1.
|
|
173
|
+
version = {1.1.0},
|
|
174
174
|
url = {https://github.com/eltonfreitas/econcomplex}
|
|
175
175
|
}
|
|
176
176
|
```
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# econcomplex
|
|
2
2
|
|
|
3
|
-
[](CHANGELOG.md)
|
|
4
|
+
[](pyproject.toml)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://github.com/eltonfreitas/econcomplex/actions/workflows/tests.yml)
|
|
7
7
|
|
|
8
8
|
**econcomplex** é uma biblioteca Python para **indicadores de complexidade
|
|
9
9
|
econômica e ciência regional**. Ela consolida, numa API única e coerente, as
|
|
@@ -31,7 +31,7 @@ difusão estratégica) que, até onde sabemos, não existe em nenhum outro pacot
|
|
|
31
31
|
| **Otimização de ECI** | Modelo de previsão com steppingstone, matriz de esforço de entrada, programa 0–1 exato para portfólios de diversificação de menor esforço, metas de crescimento (Stojkoski & Hidalgo 2026) |
|
|
32
32
|
| **Difusão estratégica** | Calibração de contágio complexo, cinco estratégias de diversificação, sequenciamento ótimo de entrada (Alshamsi, Pinheiro & Hidalgo 2018) |
|
|
33
33
|
|
|
34
|
-
São
|
|
34
|
+
São 90 funções públicas — a documentação em PDF traz a referência completa da
|
|
35
35
|
API e um guia de interpretação para cada família de indicadores.
|
|
36
36
|
|
|
37
37
|
## Instalação
|
|
@@ -46,14 +46,14 @@ Ou, para a versão de desenvolvimento mais recente direto do GitHub:
|
|
|
46
46
|
pip install git+https://github.com/eltonfreitas/econcomplex.git
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Exige Python ≥ 3.
|
|
49
|
+
Exige Python ≥ 3.10 com `numpy ≥ 1.21` (compatível com 1.x **e** 2.x),
|
|
50
50
|
`pandas ≥ 1.3`, `scipy ≥ 1.9`. Para desenvolvimento local:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
53
|
git clone https://github.com/eltonfreitas/econcomplex.git
|
|
54
54
|
cd econcomplex
|
|
55
55
|
pip install -e .[dev]
|
|
56
|
-
pytest #
|
|
56
|
+
pytest # testes + exemplos dos docstrings
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
## Começando
|
|
@@ -83,7 +83,7 @@ mat = ec.pivot_to_matrix(df, "regiao", "setor", "emprego")
|
|
|
83
83
|
eci, pci = ec.eci_pci(mat) # método do autovetor (padrão)
|
|
84
84
|
eci2, pci2 = ec.eci_pci(mat, method="fitness") # mesma chamada, outro método
|
|
85
85
|
|
|
86
|
-
phi = ec.
|
|
86
|
+
phi = ec.product_proximity(mat) # product space
|
|
87
87
|
density = ec.density(mat, phi=phi) # densidade de relatedness (0–100 %)
|
|
88
88
|
coi = ec.coi(mat, pci, phi=phi) # potencial de diversificação
|
|
89
89
|
```
|
|
@@ -156,7 +156,7 @@ curtos ligados aos mesmos objetos (`density`, `hhi`, `coi`, `pgi`, …).
|
|
|
156
156
|
|
|
157
157
|
## Validação
|
|
158
158
|
|
|
159
|
-
A suíte de
|
|
159
|
+
A suíte de testes inclui validações exatas contra a literatura: o ECI/PCI
|
|
160
160
|
por autovetor usa o solver não-simétrico correto; o módulo de difusão
|
|
161
161
|
estratégica reproduz a solução fechada de Alshamsi et al. (2018, eq. 2) na
|
|
162
162
|
rede wheel; a relatedness relativa segue Pinheiro et al. (2022, eq. 7)
|
|
@@ -171,7 +171,7 @@ recupera o ranking canônico de ECI dos países.
|
|
|
171
171
|
author = {Freitas, Elton},
|
|
172
172
|
title = {econcomplex: economic complexity and regional science indicators in Python},
|
|
173
173
|
year = {2026},
|
|
174
|
-
version = {1.
|
|
174
|
+
version = {1.1.0},
|
|
175
175
|
url = {https://github.com/eltonfreitas/econcomplex}
|
|
176
176
|
}
|
|
177
177
|
```
|
|
@@ -40,15 +40,17 @@
|
|
|
40
40
|
\textbf{Function} & \textbf{Description} \\
|
|
41
41
|
\midrule\endhead
|
|
42
42
|
\texttt{\footnotesize proximity(mat, use\_rca=True, threshold=1.0, method='max', compute='both', continuous=False, continuous\_method='correlation')} & {\small Compute product and/or location proximity matrices.} \\[2pt]
|
|
43
|
+
\texttt{\footnotesize product\_proximity(mat, use\_rca=True, threshold=1.0, method='max', continuous=False, continuous\_method='correlation')} & {\small Activity-by-activity proximity matrix (C x C), returned directly.} \\[2pt]
|
|
44
|
+
\texttt{\footnotesize location\_proximity(mat, use\_rca=True, threshold=1.0, method='max', continuous=False, continuous\_method='correlation')} & {\small Location-by-location proximity matrix (R x R), returned directly.} \\[2pt]
|
|
43
45
|
\texttt{\footnotesize continuous\_proximity(rca\_mat, method='correlation')} & {\small Continuous product proximity from a (continuous) RCA matrix.} \\[2pt]
|
|
44
46
|
\texttt{\footnotesize cosine\_proximity(mat, use\_rca=True)} & {\small Shortcut for `continuous\_proximity(rca(mat), method='cosine')`: cosine similarity between the RCA vectors of each pair of activities.} \\[2pt]
|
|
45
47
|
\texttt{\footnotesize correlation\_proximity(mat, use\_rca=True)} & {\small Shortcut for `continuous\_proximity(rca(mat), method='correlation')`: Pearson correlation between RCA vectors, rescaled to [0, 1].} \\[2pt]
|
|
46
|
-
\texttt{\footnotesize relatedness\_density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Relatedness density for each (region, activity) pair.} \\[2pt]
|
|
47
|
-
\texttt{\footnotesize density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Alias of \texttt{relatedness\_density}.} \\[2pt]
|
|
48
|
-
\texttt{\footnotesize relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Alias of \texttt{relatedness\_density}.} \\[2pt]
|
|
48
|
+
\texttt{\footnotesize relatedness\_density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Relatedness density for each (region, activity) pair.} \\[2pt]
|
|
49
|
+
\texttt{\footnotesize density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Alias of \texttt{relatedness\_density}.} \\[2pt]
|
|
50
|
+
\texttt{\footnotesize relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Alias of \texttt{relatedness\_density}.} \\[2pt]
|
|
49
51
|
\texttt{\footnotesize distance(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Distance (1 - density/100).} \\[2pt]
|
|
50
|
-
\texttt{\footnotesize relatedness\_density\_internal(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Internal relatedness density: density values for activities the region ALREADY has (M\_{rc} = 1).} \\[2pt]
|
|
51
|
-
\texttt{\footnotesize relatedness\_density\_external(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small External relatedness density: density values for activities the region does NOT yet have (M\_{rc} = 0).} \\[2pt]
|
|
52
|
+
\texttt{\footnotesize relatedness\_density\_internal(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Internal relatedness density: density values for activities the region ALREADY has (M\_{rc} = 1).} \\[2pt]
|
|
53
|
+
\texttt{\footnotesize relatedness\_density\_external(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small External relatedness density: density values for activities the region does NOT yet have (M\_{rc} = 0).} \\[2pt]
|
|
52
54
|
\texttt{\footnotesize relative\_relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Relative relatedness (Pinheiro et al.} \\[2pt]
|
|
53
55
|
\texttt{\footnotesize co\_occurrence(mat, diagonal=False)} & {\small Co-occurrence matrix: number of times two activities appear together across regions/events.} \\[2pt]
|
|
54
56
|
\texttt{\footnotesize relatedness\_index(mat, method='cosine', diagonal=False)} & {\small Pairwise relatedness index between activities from co-occurrence.} \\[2pt]
|
|
@@ -124,6 +126,7 @@
|
|
|
124
126
|
\texttt{\footnotesize growth\_rates(df, loc, act, val, time, axis=0, pct=True)} & {\small Long-format wrapper around `growth\_rate` for panel data.} \\[2pt]
|
|
125
127
|
\texttt{\footnotesize entry(mats, use\_rca=True, threshold=1.0)} & {\small Industry entry matrix: 1 when a (region, activity) transitions from absent (M=0) to present (M=1) between consecutive time periods.} \\[2pt]
|
|
126
128
|
\texttt{\footnotesize exit(mats, use\_rca=True, threshold=1.0)} & {\small Industry exit matrix: 1 when a (region, activity) transitions from present (M=1) to absent (M=0) between consecutive time periods.} \\[2pt]
|
|
129
|
+
\texttt{\footnotesize exits(mats, use\_rca=True, threshold=1.0)} & {\small Alias of \texttt{exit}.} \\[2pt]
|
|
127
130
|
\texttt{\footnotesize entry\_exit\_summary(mats, use\_rca=True, threshold=1.0)} & {\small Summary of entry and exit events per (region, activity) pair.} \\[2pt]
|
|
128
131
|
\texttt{\footnotesize entry\_tracking(df, loc, act, val, time, use\_rca=True, threshold=1.0)} & {\small Long-format wrapper around `entry` for panel data.} \\[2pt]
|
|
129
132
|
\texttt{\footnotesize exit\_tracking(df, loc, act, val, time, use\_rca=True, threshold=1.0)} & {\small Long-format wrapper around `exit` for panel data.} \\[2pt]
|
|
@@ -150,7 +153,7 @@
|
|
|
150
153
|
\texttt{\footnotesize calibrate\_steppingstone(df, loc, act, val, time, horizon=10, steppingstone=5, threshold=1.0, proximity\_method='max')} & {\small Calibrate the stepping-stone forecast model (eq.} \\[2pt]
|
|
151
154
|
\texttt{\footnotesize effort\_matrix(mat, model)} & {\small Effort W\_cp: the added RCA an economy must reach by the steppingstone period for the calibrated model to predict entry (RCA = 1) at the horizon (eq.} \\[2pt]
|
|
152
155
|
\texttt{\footnotesize forecast\_specialization(mat, model)} & {\small No-policy baseline forecast (W = 0): project RCA at t+horizon with the calibrated stepping-stone model, using entry coefficients for cells with RCA < threshold and exit coefficients otherwise.} \\[2pt]
|
|
153
|
-
\texttt{\footnotesize eci\_optimization(mat, model, delta\_eci=0.1, target\_eci=None, locations=None, solver='milp')} & {\small ECI Optimization (Stojkoski \& Hidalgo 2026): identify, per location, the minimal-effort portfolio of new specializations that raises the projected ECI to a target.} \\[2pt]
|
|
156
|
+
\texttt{\footnotesize eci\_optimization(mat, model, delta\_eci=0.1, target\_eci=None, locations=None, solver='milp', time\_limit=5.0)} & {\small ECI Optimization (Stojkoski \& Hidalgo 2026): identify, per location, the minimal-effort portfolio of new specializations that raises the projected ECI to a target.} \\[2pt]
|
|
154
157
|
\texttt{\footnotesize calibrate\_growth\_model(df, loc, time, gdppc, eci, horizon=10)} & {\small Calibrate the panel growth regression (eq.} \\[2pt]
|
|
155
158
|
\texttt{\footnotesize expected\_growth(model, eci, gdppc\_now, period=None)} & {\small Annualized log growth rate implied by the calibrated model for a given ECI and current GDP per capita (using the most recent period's fixed effect unless `period` is given).} \\[2pt]
|
|
156
159
|
\texttt{\footnotesize eci\_target\_for\_growth(model, growth\_target, gdppc\_now, period=None)} & {\small Invert the growth regression to find the ECI compatible with a target annualized log growth rate (e.g.} \\[2pt]
|
|
@@ -169,6 +172,6 @@
|
|
|
169
172
|
\toprule
|
|
170
173
|
\textbf{Function} & \textbf{Description} \\
|
|
171
174
|
\midrule\endhead
|
|
172
|
-
\texttt{\footnotesize compute\_complexity(data, cols, *, method='eigenvector', presence\_test='rca', threshold=1.0, iterations=20, proximity\_type='discrete', proximity\_method='max', pop=None, compute\_coi\_cog=True, time\_col=None)} & {\small Compute a full suite of economic complexity indicators.} \\[2pt]
|
|
175
|
+
\texttt{\footnotesize compute\_complexity(data, cols, *, method='eigenvector', presence\_test='rca', threshold=1.0, iterations=20, proximity\_type='discrete', proximity\_method='max', pop=None, compute\_coi\_cog=True, trim=True, dmin=1, umin=1, time\_col=None)} & {\small Compute a full suite of economic complexity indicators.} \\[2pt]
|
|
173
176
|
\bottomrule
|
|
174
177
|
\end{longtable}
|
|
@@ -40,15 +40,17 @@
|
|
|
40
40
|
\textbf{Fun\c{c}\~{a}o} & \textbf{Descri\c{c}\~{a}o} \\
|
|
41
41
|
\midrule\endhead
|
|
42
42
|
\texttt{\footnotesize proximity(mat, use\_rca=True, threshold=1.0, method='max', compute='both', continuous=False, continuous\_method='correlation')} & {\small Matrizes de proximidade entre produtos e/ou regi\~{o}es (discreta ou cont\'{i}nua).} \\[2pt]
|
|
43
|
+
\texttt{\footnotesize product\_proximity(mat, use\_rca=True, threshold=1.0, method='max', continuous=False, continuous\_method='correlation')} & {\small Matriz de proximidade entre atividades, devolvida diretamente (atalho de proximity).} \\[2pt]
|
|
44
|
+
\texttt{\footnotesize location\_proximity(mat, use\_rca=True, threshold=1.0, method='max', continuous=False, continuous\_method='correlation')} & {\small Matriz de proximidade entre regi\~{o}es, devolvida diretamente (atalho de proximity).} \\[2pt]
|
|
43
45
|
\texttt{\footnotesize continuous\_proximity(rca\_mat, method='correlation')} & {\small Proximidade cont\'{i}nua a partir do RCA (correla\c{c}\~{a}o ou cosseno).} \\[2pt]
|
|
44
46
|
\texttt{\footnotesize cosine\_proximity(mat, use\_rca=True)} & {\small Atalho: proximidade cont\'{i}nua por cosseno.} \\[2pt]
|
|
45
47
|
\texttt{\footnotesize correlation\_proximity(mat, use\_rca=True)} & {\small Atalho: proximidade cont\'{i}nua por correla\c{c}\~{a}o.} \\[2pt]
|
|
46
|
-
\texttt{\footnotesize relatedness\_density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Densidade de relatedness por par (regi\~{a}o, atividade), em percentual.} \\[2pt]
|
|
47
|
-
\texttt{\footnotesize density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Alias de \texttt{relatedness\_density}.} \\[2pt]
|
|
48
|
-
\texttt{\footnotesize relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Alias de \texttt{relatedness\_density}.} \\[2pt]
|
|
48
|
+
\texttt{\footnotesize relatedness\_density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Densidade de relatedness por par (regi\~{a}o, atividade), em percentual.} \\[2pt]
|
|
49
|
+
\texttt{\footnotesize density(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Alias de \texttt{relatedness\_density}.} \\[2pt]
|
|
50
|
+
\texttt{\footnotesize relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Alias de \texttt{relatedness\_density}.} \\[2pt]
|
|
49
51
|
\texttt{\footnotesize distance(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Dist\^{a}ncia: 1 -- densidade/100.} \\[2pt]
|
|
50
|
-
\texttt{\footnotesize relatedness\_density\_internal(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Densidade restrita \`{a}s atividades j\'{a} presentes.} \\[2pt]
|
|
51
|
-
\texttt{\footnotesize relatedness\_density\_external(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Densidade restrita \`{a}s atividades ausentes.} \\[2pt]
|
|
52
|
+
\texttt{\footnotesize relatedness\_density\_internal(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Densidade restrita \`{a}s atividades j\'{a} presentes.} \\[2pt]
|
|
53
|
+
\texttt{\footnotesize relatedness\_density\_external(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max', percent=True)} & {\small Densidade restrita \`{a}s atividades ausentes.} \\[2pt]
|
|
52
54
|
\texttt{\footnotesize relative\_relatedness(mat, phi=None, use\_rca=True, threshold=1.0, proximity\_method='max')} & {\small Relatedness relativa: z-score no option set (Pinheiro et al.\ 2022).} \\[2pt]
|
|
53
55
|
\texttt{\footnotesize co\_occurrence(mat, diagonal=False)} & {\small Matriz de coocorr\^{e}ncia entre atividades.} \\[2pt]
|
|
54
56
|
\texttt{\footnotesize relatedness\_index(mat, method='cosine', diagonal=False)} & {\small \'{I}ndice de relatedness por coocorr\^{e}ncia (probabilidade, associa\c{c}\~{a}o, cosseno, Jaccard).} \\[2pt]
|
|
@@ -124,6 +126,7 @@
|
|
|
124
126
|
\texttt{\footnotesize growth\_rates(df, loc, act, val, time, axis=0, pct=True)} & {\small Crescimento em painel longo, entre per\'{i}odos consecutivos.} \\[2pt]
|
|
125
127
|
\texttt{\footnotesize entry(mats, use\_rca=True, threshold=1.0)} & {\small Entradas: transi\c{c}\~{o}es 0 para 1 na especializa\c{c}\~{a}o.} \\[2pt]
|
|
126
128
|
\texttt{\footnotesize exit(mats, use\_rca=True, threshold=1.0)} & {\small Sa\'{i}das: transi\c{c}\~{o}es 1 para 0 na especializa\c{c}\~{a}o.} \\[2pt]
|
|
129
|
+
\texttt{\footnotesize exits(mats, use\_rca=True, threshold=1.0)} & {\small Alias de \texttt{exit}.} \\[2pt]
|
|
127
130
|
\texttt{\footnotesize entry\_exit\_summary(mats, use\_rca=True, threshold=1.0)} & {\small Resumo de entradas e sa\'{i}das por par (regi\~{a}o, atividade).} \\[2pt]
|
|
128
131
|
\texttt{\footnotesize entry\_tracking(df, loc, act, val, time, use\_rca=True, threshold=1.0)} & {\small Entradas em formato longo (painel).} \\[2pt]
|
|
129
132
|
\texttt{\footnotesize exit\_tracking(df, loc, act, val, time, use\_rca=True, threshold=1.0)} & {\small Sa\'{i}das em formato longo (painel).} \\[2pt]
|
|
@@ -150,7 +153,7 @@
|
|
|
150
153
|
\texttt{\footnotesize calibrate\_steppingstone(df, loc, act, val, time, horizon=10, steppingstone=5, threshold=1.0, proximity\_method='max')} & {\small Calibra o modelo forward com steppingstone (OLS de entrada/sa\'{i}da).} \\[2pt]
|
|
151
154
|
\texttt{\footnotesize effort\_matrix(mat, model)} & {\small Esfor\c{c}o $W_{cp}$: RCA adicional necess\'{a}rio para entrar em cada atividade.} \\[2pt]
|
|
152
155
|
\texttt{\footnotesize forecast\_specialization(mat, model)} & {\small Proje\c{c}\~{a}o sem pol\'{i}tica (W=0): RCA, Mcp, PCI e ECI futuros.} \\[2pt]
|
|
153
|
-
\texttt{\footnotesize eci\_optimization(mat, model, delta\_eci=0.1, target\_eci=None, locations=None, solver='milp')} & {\small Programa 0--1: portf\'{o}lio de menor esfor\c{c}o para atingir o ECI alvo.} \\[2pt]
|
|
156
|
+
\texttt{\footnotesize eci\_optimization(mat, model, delta\_eci=0.1, target\_eci=None, locations=None, solver='milp', time\_limit=5.0)} & {\small Programa 0--1: portf\'{o}lio de menor esfor\c{c}o para atingir o ECI alvo.} \\[2pt]
|
|
154
157
|
\texttt{\footnotesize calibrate\_growth\_model(df, loc, time, gdppc, eci, horizon=10)} & {\small Regress\~{a}o de crescimento em painel (ECI, converg\^{e}ncia, intera\c{c}\~{a}o).} \\[2pt]
|
|
155
158
|
\texttt{\footnotesize expected\_growth(model, eci, gdppc\_now, period=None)} & {\small Crescimento anual esperado dado o ECI e o PIB per capita.} \\[2pt]
|
|
156
159
|
\texttt{\footnotesize eci\_target\_for\_growth(model, growth\_target, gdppc\_now, period=None)} & {\small Inverte a regress\~{a}o: ECI compat\'{i}vel com a meta de crescimento.} \\[2pt]
|
|
@@ -169,6 +172,6 @@
|
|
|
169
172
|
\toprule
|
|
170
173
|
\textbf{Fun\c{c}\~{a}o} & \textbf{Descri\c{c}\~{a}o} \\
|
|
171
174
|
\midrule\endhead
|
|
172
|
-
\texttt{\footnotesize compute\_complexity(data, cols, *, method='eigenvector', presence\_test='rca', threshold=1.0, iterations=20, proximity\_type='discrete', proximity\_method='max', pop=None, compute\_coi\_cog=True, time\_col=None)} & {\small Pipeline completo: todos os indicadores a partir do DataFrame longo (suporta painel).} \\[2pt]
|
|
175
|
+
\texttt{\footnotesize compute\_complexity(data, cols, *, method='eigenvector', presence\_test='rca', threshold=1.0, iterations=20, proximity\_type='discrete', proximity\_method='max', pop=None, compute\_coi\_cog=True, trim=True, dmin=1, umin=1, time\_col=None)} & {\small Pipeline completo: todos os indicadores a partir do DataFrame longo (suporta painel).} \\[2pt]
|
|
173
176
|
\bottomrule
|
|
174
177
|
\end{longtable}
|
|
Binary file
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
\vspace*{3cm}
|
|
167
167
|
{\Huge\bfseries\color{tblhead} econcomplex}\par
|
|
168
168
|
\vspace{0.5cm}
|
|
169
|
-
{\large\bfseries Technical Documentation --- Version 1.
|
|
169
|
+
{\large\bfseries Technical Documentation --- Version 1.1.0}\par
|
|
170
170
|
\vspace{1cm}
|
|
171
171
|
\rule{10cm}{0.8pt}\par
|
|
172
172
|
\vspace{0.8cm}
|
|
@@ -179,10 +179,10 @@
|
|
|
179
179
|
\vspace{3cm}
|
|
180
180
|
{\small\color{pygray}
|
|
181
181
|
Dependencies: \texttt{numpy $\geq$ 1.21}, \texttt{pandas $\geq$ 1.3}, \texttt{scipy $\geq$ 1.9}\\[4pt]
|
|
182
|
-
Compatible with Python 3.
|
|
182
|
+
Compatible with Python 3.10+ (NumPy 1.x and 2.x)
|
|
183
183
|
}\par
|
|
184
184
|
\vfill
|
|
185
|
-
{\small\color{pygray}
|
|
185
|
+
{\small\color{pygray} November 2026}
|
|
186
186
|
\end{titlepage}
|
|
187
187
|
|
|
188
188
|
%% --- Table of contents --------------------------------------------------
|
|
@@ -227,7 +227,7 @@ python3 -c "import econcomplex as ec; print(ec.__version__)"
|
|
|
227
227
|
\subsection{Module Structure}
|
|
228
228
|
|
|
229
229
|
\begin{center}
|
|
230
|
-
\begin{tabular}{
|
|
230
|
+
\begin{tabular}{l>{\raggedright\arraybackslash}p{10cm}}
|
|
231
231
|
\toprule
|
|
232
232
|
\textbf{Module} & \textbf{Contents} \\
|
|
233
233
|
\midrule
|
|
@@ -260,15 +260,16 @@ function (no duplicated code or computation).
|
|
|
260
260
|
|
|
261
261
|
\begin{center}
|
|
262
262
|
\renewcommand{\arraystretch}{1.3}
|
|
263
|
-
\
|
|
263
|
+
\small
|
|
264
|
+
\begin{tabular}{>{\raggedright\arraybackslash}p{5.2cm}>{\raggedright\arraybackslash}p{10.4cm}}
|
|
264
265
|
\toprule
|
|
265
266
|
\textbf{Entry point} & \textbf{Delegates to (advanced)} \\
|
|
266
267
|
\midrule
|
|
267
268
|
\texttt{eci\_pci(method=...)} & \texttt{eci\_pci\_eigenvector},
|
|
268
269
|
\texttt{method\_of\_reflections}, \texttt{fitness\_complexity}
|
|
269
270
|
(variants: \texttt{mor\_regions}, \texttt{mor\_activities}) \\
|
|
270
|
-
\texttt{proximity(continuous
|
|
271
|
-
\texttt{continuous\_proximity}; shortcuts \texttt{cosine\_proximity},
|
|
271
|
+
\texttt{proximity(continuous=...)} &
|
|
272
|
+
\texttt{continuous\_proximity}; shortcuts \texttt{product\_proximity}, \texttt{location\_proximity} (return the matrix), \texttt{cosine\_proximity},
|
|
272
273
|
\texttt{correlation\_proximity} \\
|
|
273
274
|
\texttt{compute\_complexity()} & full per-period pipeline over
|
|
274
275
|
\texttt{eci\_pci}, \texttt{proximity}, \texttt{density}, COI/COG \\
|
|
@@ -288,6 +289,7 @@ function (no duplicated code or computation).
|
|
|
288
289
|
\texttt{pgi} / \texttt{peii} & \texttt{product\_gini\_index} / \texttt{product\_emissions\_index} \\
|
|
289
290
|
\texttt{spec\_coefficient} & \texttt{specialization\_coefficient} \\
|
|
290
291
|
\texttt{cross\_space\_proximity} & \texttt{cross\_proximity} \\
|
|
292
|
+
\texttt{exits} & \texttt{exit} (name that does not shadow the Python builtin) \\
|
|
291
293
|
\texttt{location\_quotient} & \texttt{rca} (identical formula) \\
|
|
292
294
|
\bottomrule
|
|
293
295
|
\end{tabular}
|
|
@@ -347,6 +349,17 @@ $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
|
|
|
347
349
|
not mixed).
|
|
348
350
|
\end{enumerate}
|
|
349
351
|
|
|
352
|
+
\begin{notebox}
|
|
353
|
+
The library enforces rules 2 and 3: a matrix with negative, \texttt{NaN}
|
|
354
|
+
or infinite cells raises a \texttt{ValueError} that says how many cells
|
|
355
|
+
are affected. Auxiliary inputs given as labelled pandas objects (a GDP or
|
|
356
|
+
population \texttt{Series}, a PCI vector, a proximity matrix) are matched
|
|
357
|
+
to the matrix \textbf{by label}, so their order does not matter and extra
|
|
358
|
+
labels are ignored; a label of the matrix that is absent raises an error
|
|
359
|
+
naming it. Lists, arrays and \texttt{Series} with a default integer index
|
|
360
|
+
are taken by position.
|
|
361
|
+
\end{notebox}
|
|
362
|
+
|
|
350
363
|
% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
|
351
364
|
\subsection{Column Names --- \texttt{cols} Dictionary}
|
|
352
365
|
|
|
@@ -444,8 +457,9 @@ df = pd.read_excel("data.xlsx", sheet_name="Sheet1",
|
|
|
444
457
|
Exports by country $\times$ product (HS) $\times$ year.
|
|
445
458
|
Available at \url{https://atlas.cid.harvard.edu/}.
|
|
446
459
|
\item[\textbf{Simulated data (testing)}]
|
|
447
|
-
Use \fn{ec.make\_sample\_data(
|
|
448
|
-
|
|
460
|
+
{\sloppy Use \fn{ec.make\_sample\_data()} to generate a synthetic
|
|
461
|
+
DataFrame; \fn{n\_locs}, \fn{n\_acts} and \fn{seed} set its size and
|
|
462
|
+
the random seed.\par}
|
|
449
463
|
\end{description}
|
|
450
464
|
|
|
451
465
|
%% ============================================================
|
|
@@ -501,7 +515,7 @@ import sys
|
|
|
501
515
|
sys.path.insert(0, "/path/to/econcomplex")
|
|
502
516
|
|
|
503
517
|
import econcomplex as ec
|
|
504
|
-
print(ec.__version__) # 1.
|
|
518
|
+
print(ec.__version__) # 1.1.0
|
|
505
519
|
\end{lstlisting}
|
|
506
520
|
|
|
507
521
|
% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
|
@@ -911,7 +925,9 @@ model = ec.calibrate_steppingstone(df, "region", "sector", "jobs",
|
|
|
911
925
|
W = ec.effort_matrix(mat, model) # added RCA per candidate
|
|
912
926
|
fc = ec.forecast_specialization(mat, model) # rca, mcp, pci, eci
|
|
913
927
|
|
|
914
|
-
# 3. Minimal-effort portfolio raising each location's ECI by 0.1
|
|
928
|
+
# 3. Minimal-effort portfolio raising each location's ECI by 0.1.
|
|
929
|
+
# time_limit caps the exact solver per location (default 5 s);
|
|
930
|
+
# the `optimal` column says whether optimality was proven.
|
|
915
931
|
portfolio = ec.eci_optimization(mat, model, delta_eci=0.1)
|
|
916
932
|
|
|
917
933
|
# 4. Optional: growth targeting - convert a growth target (3.5%/yr)
|
|
@@ -962,6 +978,8 @@ def compute_complexity(
|
|
|
962
978
|
proximity_method: str = "max", # 'max' | 'sqrt' | 'min'
|
|
963
979
|
pop: pd.DataFrame | None = None, # population (for 'rpop'/'both')
|
|
964
980
|
compute_coi_cog: bool = True,
|
|
981
|
+
trim: bool = True, # pre-trim degenerate units
|
|
982
|
+
dmin: int = 1, umin: int = 1, # core thresholds (use 2,2 if sparse)
|
|
965
983
|
time_col: str | None = None,
|
|
966
984
|
) -> pd.DataFrame:
|
|
967
985
|
"""
|
|
@@ -971,6 +989,16 @@ def compute_complexity(
|
|
|
971
989
|
"""
|
|
972
990
|
\end{lstlisting}
|
|
973
991
|
|
|
992
|
+
\begin{notebox}
|
|
993
|
+
\texttt{compute\_complexity} is a thin \textbf{orchestration layer}: it
|
|
994
|
+
calls the same public functions you would call by hand (\fn{rca},
|
|
995
|
+
\fn{mcp}, \fn{diversity}, \fn{ubiquity}, \fn{eci\_pci}, \fn{proximity},
|
|
996
|
+
\fn{relatedness\_density}, \fn{distance}, \fn{coi}/\fn{cog}) and merges
|
|
997
|
+
the results back into long format, looping over periods for panels. It
|
|
998
|
+
is the convenience entry point for the common case; for fine-grained
|
|
999
|
+
control, call the matrix-level functions directly.
|
|
1000
|
+
\end{notebox}
|
|
1001
|
+
|
|
974
1002
|
\subsection{Parameters}
|
|
975
1003
|
|
|
976
1004
|
\begin{center}
|
|
@@ -989,6 +1017,8 @@ def compute_complexity(
|
|
|
989
1017
|
\texttt{proximity\_method} & \texttt{str} & Proximity normalization \\
|
|
990
1018
|
\texttt{pop} & \texttt{DataFrame} & Population, required for RPOP \\
|
|
991
1019
|
\texttt{compute\_coi\_cog} & \texttt{bool} & Compute COI and COG (slower) \\
|
|
1020
|
+
\texttt{trim} & \texttt{bool} & Pre-trim degenerate units (default: True) \\
|
|
1021
|
+
\texttt{dmin}, \texttt{umin} & \texttt{int} & Core thresholds forwarded to \fn{eci\_pci}; use 2 for sparse data \\
|
|
992
1022
|
\bottomrule
|
|
993
1023
|
\end{tabular}
|
|
994
1024
|
\end{center}
|
|
@@ -996,7 +1026,8 @@ def compute_complexity(
|
|
|
996
1026
|
\begin{notebox}
|
|
997
1027
|
Degenerate units (zero diversity or ubiquity) are automatically
|
|
998
1028
|
trimmed by the complexity step and returned as \texttt{NaN}
|
|
999
|
-
(see \fn{trim\_core}).
|
|
1029
|
+
(see \fn{trim\_core}). For sparse subnational data, pass
|
|
1030
|
+
\texttt{dmin=2, umin=2} to restrict to the well-connected core.
|
|
1000
1031
|
\end{notebox}
|
|
1001
1032
|
|
|
1002
1033
|
%% ============================================================
|
|
@@ -1195,11 +1226,13 @@ print(best["sequence"][:10], best["improvement"])
|
|
|
1195
1226
|
%% ============================================================
|
|
1196
1227
|
\section{API Reference}
|
|
1197
1228
|
|
|
1198
|
-
|
|
1229
|
+
\begin{sloppypar}
|
|
1230
|
+
Complete inventory of the 90 public functions, grouped by module.
|
|
1199
1231
|
Signatures show parameter names and defaults; see the in-code
|
|
1200
1232
|
docstrings (\texttt{help(ec.function)}) for full parameter
|
|
1201
1233
|
documentation. This section is auto-generated from the installed
|
|
1202
1234
|
package by \texttt{docs/generate\_api\_reference.py}.
|
|
1235
|
+
\end{sloppypar}
|
|
1203
1236
|
|
|
1204
1237
|
\input{api_reference_en}
|
|
1205
1238
|
|
|
@@ -1264,7 +1297,7 @@ original papers of the indicators used (see References).
|
|
|
1264
1297
|
|
|
1265
1298
|
\begin{lstlisting}[language={}, caption={Check the library version}]
|
|
1266
1299
|
import econcomplex as ec
|
|
1267
|
-
print(ec.__version__) # 1.
|
|
1300
|
+
print(ec.__version__) # 1.1.0
|
|
1268
1301
|
\end{lstlisting}
|
|
1269
1302
|
|
|
1270
1303
|
\end{document}
|
|
Binary file
|