hiveplotlib 0.27.0__tar.gz → 0.28.1__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 (46) hide show
  1. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/LICENSE +2 -2
  2. {hiveplotlib-0.27.0/src/hiveplotlib.egg-info → hiveplotlib-0.28.1}/PKG-INFO +26 -50
  3. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/README.md +14 -9
  4. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/pyproject.toml +19 -14
  5. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/__init__.py +0 -1
  6. hiveplotlib-0.28.1/src/hiveplotlib/converters.py +166 -0
  7. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/datasets/international_trade.py +1 -1
  8. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/datasets/toy_hive_plots.py +96 -25
  9. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_metadata_2019_8112.json +1 -1
  10. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/edges.py +8 -2
  11. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/exceptions/hive_plot.py +11 -0
  12. hiveplotlib-0.28.1/src/hiveplotlib/graph_features/__init__.py +858 -0
  13. hiveplotlib-0.28.1/src/hiveplotlib/graph_features/networkx/__init__.py +103 -0
  14. hiveplotlib-0.28.1/src/hiveplotlib/graph_features/networkx/_helpers.py +177 -0
  15. hiveplotlib-0.28.1/src/hiveplotlib/graph_features/networkx/edge_metrics.py +259 -0
  16. hiveplotlib-0.28.1/src/hiveplotlib/graph_features/networkx/node_metrics.py +913 -0
  17. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/hiveplot.py +817 -432
  18. hiveplotlib-0.28.1/src/hiveplotlib/hiveplot_matrix.py +2274 -0
  19. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/utils.py +2 -2
  20. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/bokeh.py +28 -7
  21. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/hiveplot_matrix.py +2 -2
  22. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/holoviews.py +3 -1
  23. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1/src/hiveplotlib.egg-info}/PKG-INFO +26 -50
  24. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib.egg-info/SOURCES.txt +5 -1
  25. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib.egg-info/requires.txt +8 -9
  26. hiveplotlib-0.27.0/setup.py +0 -8
  27. hiveplotlib-0.27.0/src/hiveplotlib/converters.py +0 -44
  28. hiveplotlib-0.27.0/src/hiveplotlib/hiveplot_matrix.py +0 -1274
  29. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/MANIFEST.in +0 -0
  30. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/setup.cfg +0 -0
  31. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/axis.py +0 -0
  32. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/datasets/__init__.py +0 -0
  33. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/datasets/toy_p2cps.py +0 -0
  34. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_2019_8112.csv +0 -0
  35. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/exceptions/__init__.py +0 -0
  36. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/exceptions/node.py +0 -0
  37. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/node.py +0 -0
  38. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/p2cp.py +0 -0
  39. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/__init__.py +0 -0
  40. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/base.py +0 -0
  41. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/datashader.py +0 -0
  42. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/input_checks.py +0 -0
  43. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/matplotlib.py +0 -0
  44. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib/viz/plotly.py +0 -0
  45. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib.egg-info/dependency_links.txt +0 -0
  46. {hiveplotlib-0.27.0 → hiveplotlib-0.28.1}/src/hiveplotlib.egg-info/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 - 2024, Geometric Data Analytics, Inc.
1
+ Copyright (c) 2020 - 2026, Gary Koplik
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
@@ -11,7 +11,7 @@ Redistributions in binary form must reproduce the above copyright notice,
11
11
  this list of conditions and the following disclaimer in the documentation
12
12
  and/or other materials provided with the distribution.
13
13
 
14
- Neither the name of Geometric Data Analytics nor the names of any contributors
14
+ Neither the name of Gary Koplik nor the names of any contributors
15
15
  may be used to endorse or promote products derived from this software
16
16
  without specific prior written permission.
17
17
 
@@ -1,39 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hiveplotlib
3
- Version: 0.27.0
3
+ Version: 0.28.1
4
4
  Summary: Visualize Network Data with Hive Plots
5
- Author-email: Gary Koplik <gary.koplik@geomdata.com>
6
- License: Copyright (c) 2020 - 2024, Geometric Data Analytics, Inc.
7
- All rights reserved.
8
-
9
- Redistribution and use in source and binary forms, with or without modification,
10
- are permitted provided that the following conditions are met:
11
-
12
- Redistributions of source code must retain the above copyright notice,
13
- this list of conditions and the following disclaimer.
14
-
15
- Redistributions in binary form must reproduce the above copyright notice,
16
- this list of conditions and the following disclaimer in the documentation
17
- and/or other materials provided with the distribution.
18
-
19
- Neither the name of Geometric Data Analytics nor the names of any contributors
20
- may be used to endorse or promote products derived from this software
21
- without specific prior written permission.
22
-
23
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33
- THE POSSIBILITY OF SUCH DAMAGE.
34
-
5
+ Author-email: Gary Koplik <gary.koplik@gmail.com>
6
+ License-Expression: BSD-3-Clause
35
7
  Project-URL: Documentation, https://hiveplotlib.readthedocs.io/stable/
36
- Project-URL: Source, https://gitlab.com/geomdata/hiveplotlib
8
+ Project-URL: Source, https://gitlab.com/hiveplotlib/hiveplotlib
37
9
  Requires-Python: >=3.10
38
10
  Description-Content-Type: text/markdown
39
11
  License-File: LICENSE
@@ -48,19 +20,17 @@ Requires-Dist: datashader; extra == "datashader"
48
20
  Requires-Dist: numba>0.54.0; extra == "datashader"
49
21
  Requires-Dist: seaborn; extra == "datashader"
50
22
  Provides-Extra: dev
51
- Requires-Dist: bokeh>=3.0.0; extra == "dev"
52
23
  Requires-Dist: cartopy; extra == "dev"
53
- Requires-Dist: dask[dataframe]; extra == "dev"
54
- Requires-Dist: datashader; extra == "dev"
55
24
  Requires-Dist: flexitext; extra == "dev"
56
25
  Requires-Dist: geopandas; extra == "dev"
57
- Requires-Dist: holoviews>=1.15; extra == "dev"
26
+ Requires-Dist: hiveplotlib[bokeh]; extra == "dev"
27
+ Requires-Dist: hiveplotlib[datashader]; extra == "dev"
28
+ Requires-Dist: hiveplotlib[holoviews]; extra == "dev"
29
+ Requires-Dist: hiveplotlib[networkx]; extra == "dev"
30
+ Requires-Dist: hiveplotlib[plotly]; extra == "dev"
58
31
  Requires-Dist: jupyter; extra == "dev"
59
- Requires-Dist: networkx; extra == "dev"
60
- Requires-Dist: numba>0.54.0; extra == "dev"
61
- Requires-Dist: plotly; extra == "dev"
32
+ Requires-Dist: nx-parallel; extra == "dev"
62
33
  Requires-Dist: pybadges; extra == "dev"
63
- Requires-Dist: seaborn; extra == "dev"
64
34
  Requires-Dist: tqdm; extra == "dev"
65
35
  Provides-Extra: docs
66
36
  Requires-Dist: ipywidgets; extra == "docs"
@@ -76,6 +46,7 @@ Requires-Dist: holoviews>=1.15; extra == "holoviews"
76
46
  Requires-Dist: numba>0.54.0; extra == "holoviews"
77
47
  Provides-Extra: networkx
78
48
  Requires-Dist: networkx; extra == "networkx"
49
+ Requires-Dist: scipy; extra == "networkx"
79
50
  Provides-Extra: perf
80
51
  Requires-Dist: pyinstrument; extra == "perf"
81
52
  Requires-Dist: snakeviz; extra == "perf"
@@ -83,7 +54,7 @@ Requires-Dist: memory_profiler; extra == "perf"
83
54
  Provides-Extra: plotly
84
55
  Requires-Dist: plotly; extra == "plotly"
85
56
  Provides-Extra: ruff
86
- Requires-Dist: ruff; extra == "ruff"
57
+ Requires-Dist: ruff==0.15.22; extra == "ruff"
87
58
  Provides-Extra: testing
88
59
  Requires-Dist: pytest; extra == "testing"
89
60
  Requires-Dist: pytest-cov; extra == "testing"
@@ -99,13 +70,14 @@ Dynamic: license-file
99
70
 
100
71
  A plotting package for generating and visualizing static Hive Plots in Python.
101
72
 
102
- ![Supported Python Versions Matches PSF support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/python_badge.svg)
73
+ ![Supported Python Versions Matches PSF support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/python_badge.svg)
103
74
 
104
- [![Matplotlib Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/matplotlib_badge.svg)](https://matplotlib.org/)
105
- [![Bokeh Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/bokeh_badge.svg)](https://docs.bokeh.org/en/latest/)
106
- [![Holoviews Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/holoviews_badge.svg)](https://holoviews.org/index.html)
107
- [![Plotly Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/plotly_badge.svg)](https://plotly.com/python/)
108
- [![Datashader Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/datashader_badge.svg)](https://datashader.org/)
75
+ [![Matplotlib Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/matplotlib_badge.svg)](https://matplotlib.org/)
76
+ [![Bokeh Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/bokeh_badge.svg)](https://docs.bokeh.org/en/latest/)
77
+ [![Holoviews Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/holoviews_badge.svg)](https://holoviews.org/index.html)
78
+ [![Plotly Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/plotly_badge.svg)](https://plotly.com/python/)
79
+ [![Datashader Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/datashader_badge.svg)](https://datashader.org/)
80
+ [![NetworkX Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/networkx_badge.svg)](https://networkx.org/)
109
81
 
110
82
  # Installation
111
83
 
@@ -129,6 +101,10 @@ and [plotly](https://plotly.com/python/) visualizations, which can be installed
129
101
  `hiveplotlib` also supports large network visualization via the [datashader](https://datashader.org/) backend,
130
102
  which can be installed as `pip install hiveplotlib[datashader]`.
131
103
 
104
+ Beyond the visualization backends, `hiveplotlib` integrates with [networkx](https://networkx.org/): build a hive plot
105
+ directly from a `networkx` graph and compute graph metrics on it. Install this integration with
106
+ `pip install hiveplotlib[networkx]`.
107
+
132
108
  # How to Use and Examples
133
109
 
134
110
  For more on how to use the software and examples, see the
@@ -140,7 +116,7 @@ We recommend starting with our
140
116
  [Quick Start Hive Plots](https://hiveplotlib.readthedocs.io/stable/notebooks/quick_hive_plots.html) pages.
141
117
 
142
118
  All the example notebooks are available for download as `jupyter` notebooks in the repository under the
143
- [examples](https://gitlab.com/geomdata/hiveplotlib/-/tree/master/examples) directory.
119
+ [examples](https://gitlab.com/hiveplotlib/hiveplotlib/-/tree/master/examples) directory.
144
120
 
145
121
  To install this environment and associated `jupyter` kernel used to run the notebooks, clone the repository and run:
146
122
 
@@ -158,7 +134,7 @@ For more on Hive Plots, see our
158
134
 
159
135
  For additional resources, see:
160
136
 
161
- - [http://www.hiveplot.com/](http://www.hiveplot.com/)
137
+ - [https://hiveplot.com/](https://hiveplot.com/)
162
138
 
163
139
  - Krzywinski M, Birol I, Jones S, Marra M (2011). Hive Plots — Rational Approach to
164
140
  Visualizing Networks. Briefings in Bioinformatics (early access 9 December 2011,
@@ -166,7 +142,7 @@ doi: 10.1093/bib/bbr069).
166
142
 
167
143
  # Contributing
168
144
 
169
- For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/geomdata/hiveplotlib/-/blob/master/CONTRIBUTING.md)
145
+ For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/hiveplotlib/hiveplotlib/-/blob/master/CONTRIBUTING.md)
170
146
 
171
147
  ## Acknowledgements
172
148
 
@@ -2,13 +2,14 @@
2
2
 
3
3
  A plotting package for generating and visualizing static Hive Plots in Python.
4
4
 
5
- ![Supported Python Versions Matches PSF support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/python_badge.svg)
5
+ ![Supported Python Versions Matches PSF support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/python_badge.svg)
6
6
 
7
- [![Matplotlib Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/matplotlib_badge.svg)](https://matplotlib.org/)
8
- [![Bokeh Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/bokeh_badge.svg)](https://docs.bokeh.org/en/latest/)
9
- [![Holoviews Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/holoviews_badge.svg)](https://holoviews.org/index.html)
10
- [![Plotly Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/plotly_badge.svg)](https://plotly.com/python/)
11
- [![Datashader Support](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/datashader_badge.svg)](https://datashader.org/)
7
+ [![Matplotlib Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/matplotlib_badge.svg)](https://matplotlib.org/)
8
+ [![Bokeh Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/bokeh_badge.svg)](https://docs.bokeh.org/en/latest/)
9
+ [![Holoviews Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/holoviews_badge.svg)](https://holoviews.org/index.html)
10
+ [![Plotly Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/plotly_badge.svg)](https://plotly.com/python/)
11
+ [![Datashader Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/datashader_badge.svg)](https://datashader.org/)
12
+ [![NetworkX Support](https://gitlab.com/hiveplotlib/hiveplotlib/-/raw/master/.gitlab/networkx_badge.svg)](https://networkx.org/)
12
13
 
13
14
  # Installation
14
15
 
@@ -32,6 +33,10 @@ and [plotly](https://plotly.com/python/) visualizations, which can be installed
32
33
  `hiveplotlib` also supports large network visualization via the [datashader](https://datashader.org/) backend,
33
34
  which can be installed as `pip install hiveplotlib[datashader]`.
34
35
 
36
+ Beyond the visualization backends, `hiveplotlib` integrates with [networkx](https://networkx.org/): build a hive plot
37
+ directly from a `networkx` graph and compute graph metrics on it. Install this integration with
38
+ `pip install hiveplotlib[networkx]`.
39
+
35
40
  # How to Use and Examples
36
41
 
37
42
  For more on how to use the software and examples, see the
@@ -43,7 +48,7 @@ We recommend starting with our
43
48
  [Quick Start Hive Plots](https://hiveplotlib.readthedocs.io/stable/notebooks/quick_hive_plots.html) pages.
44
49
 
45
50
  All the example notebooks are available for download as `jupyter` notebooks in the repository under the
46
- [examples](https://gitlab.com/geomdata/hiveplotlib/-/tree/master/examples) directory.
51
+ [examples](https://gitlab.com/hiveplotlib/hiveplotlib/-/tree/master/examples) directory.
47
52
 
48
53
  To install this environment and associated `jupyter` kernel used to run the notebooks, clone the repository and run:
49
54
 
@@ -61,7 +66,7 @@ For more on Hive Plots, see our
61
66
 
62
67
  For additional resources, see:
63
68
 
64
- - [http://www.hiveplot.com/](http://www.hiveplot.com/)
69
+ - [https://hiveplot.com/](https://hiveplot.com/)
65
70
 
66
71
  - Krzywinski M, Birol I, Jones S, Marra M (2011). Hive Plots — Rational Approach to
67
72
  Visualizing Networks. Briefings in Bioinformatics (early access 9 December 2011,
@@ -69,7 +74,7 @@ doi: 10.1093/bib/bbr069).
69
74
 
70
75
  # Contributing
71
76
 
72
- For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/geomdata/hiveplotlib/-/blob/master/CONTRIBUTING.md)
77
+ For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/hiveplotlib/hiveplotlib/-/blob/master/CONTRIBUTING.md)
73
78
 
74
79
  ## Acknowledgements
75
80
 
@@ -7,14 +7,15 @@ build-backend = "setuptools.build_meta"
7
7
  [project]
8
8
  name = "hiveplotlib"
9
9
  requires-python = ">=3.10"
10
- version = "0.27.0"
10
+ version = "0.28.1"
11
11
  authors = [
12
- {name="Gary Koplik", email="gary.koplik@geomdata.com"}
12
+ {name="Gary Koplik", email="gary.koplik@gmail.com"}
13
13
  ]
14
14
  description = "Visualize Network Data with Hive Plots"
15
15
  readme = "README.md"
16
- license = {file = "LICENSE"}
17
- urls = {Documentation="https://hiveplotlib.readthedocs.io/stable/", Source="https://gitlab.com/geomdata/hiveplotlib" }
16
+ license = "BSD-3-Clause"
17
+ license-files = ["LICENSE"]
18
+ urls = {Documentation="https://hiveplotlib.readthedocs.io/stable/", Source="https://gitlab.com/hiveplotlib/hiveplotlib" }
18
19
 
19
20
 
20
21
  dependencies = [
@@ -38,19 +39,17 @@ datashader = [
38
39
 
39
40
  # developer dependencies
40
41
  dev = [
41
- "bokeh>=3.0.0",
42
42
  "cartopy",
43
- "dask[dataframe]", # https://github.com/holoviz/datashader/issues/1319
44
- "datashader",
45
43
  "flexitext",
46
44
  "geopandas",
47
- "holoviews>=1.15",
45
+ "hiveplotlib[bokeh]",
46
+ "hiveplotlib[datashader]",
47
+ "hiveplotlib[holoviews]",
48
+ "hiveplotlib[networkx]",
49
+ "hiveplotlib[plotly]",
48
50
  "jupyter",
49
- "networkx",
50
- "numba>0.54.0", # https://github.com/numba/numba/issues/9708
51
- "plotly",
51
+ "nx-parallel", # CI-testable networkx dispatch backend for `graph_metric_backend` tests
52
52
  "pybadges",
53
- "seaborn",
54
53
  "tqdm",
55
54
  ]
56
55
 
@@ -72,7 +71,8 @@ holoviews = [
72
71
  ]
73
72
 
74
73
  networkx = [
75
- "networkx"
74
+ "networkx",
75
+ "scipy", # for some graph feature computations
76
76
  ]
77
77
 
78
78
  # performance profiling extras
@@ -88,7 +88,7 @@ plotly = [
88
88
 
89
89
  # ruff code hygeine checks
90
90
  ruff = [
91
- "ruff",
91
+ "ruff==0.15.22", # pinned for the life of 0.28.x, ruff 0.16 expanded its default rules and formats markdown
92
92
  ]
93
93
 
94
94
  testing = [
@@ -105,6 +105,11 @@ ty = [
105
105
  "ty==0.0.20", # pinning for now, 0.0.21 would require non trivial type hint changes that affect the user
106
106
  ]
107
107
 
108
+ [tool.uv]
109
+ # scope `uv lock` and `uv audit` to python 3.11+. Python 3.10's resolution is stuck on versions with unfixable advisories
110
+ # (e.g. pillow 13 requires 3.11+), which would keep `uv_audit` red. Python 3.10 installs and CI tests are unaffected.
111
+ environments = ["python_version >= '3.11'"]
112
+
108
113
  [tool.setuptools.packages.find]
109
114
  where = ["src"]
110
115
  include = ["hiveplotlib*"]
@@ -10,7 +10,6 @@ from hiveplotlib.hiveplot import ( # noqa: F401
10
10
  SUPPORTED_VIZ_BACKENDS,
11
11
  BaseHivePlot,
12
12
  HivePlot,
13
- hive_plot_n_axes,
14
13
  )
15
14
  from hiveplotlib.hiveplot_matrix import ( # noqa: F401
16
15
  HPM_SUPPORTED_VIZ_BACKENDS,
@@ -0,0 +1,166 @@
1
+ # converters.py
2
+
3
+ """
4
+ Converters from various data structures to ``hiveplotlib``-ready structures.
5
+ """
6
+
7
+ from typing import Optional
8
+
9
+ import pandas as pd
10
+
11
+ from hiveplotlib import Edges, NodeCollection
12
+
13
+ try:
14
+ import networkx as nx
15
+ except ImportError as ie: # pragma: no cover
16
+ msg = "`networkx` dependencies not installed, but can be installed by running `pip install hiveplotlib[networkx]`"
17
+ raise ImportError(msg) from ie
18
+
19
+
20
+ def networkx_to_nodes_edges(
21
+ graph: nx.Graph,
22
+ unique_id_name: str = "unique_id",
23
+ check_uniqueness: bool = True,
24
+ ) -> tuple[NodeCollection, Edges]:
25
+ """
26
+ Take a ``networkx`` graph and return ``hiveplotlib``-friendly data structures.
27
+
28
+ Specifically, returns a ``NodeCollection`` instance of node data and an ``Edges`` instance of
29
+ edge data. These outputs can be fed directly into :py:func:`~hiveplotlib.HivePlot`.
30
+
31
+ :param graph: ``networkx`` graph (any of :py:class:`~networkx.Graph`, :py:class:`~networkx.DiGraph`,
32
+ :py:class:`~networkx.MultiGraph`, or :py:class:`~networkx.MultiDiGraph`).
33
+ :param unique_id_name: name to use for unique IDs.
34
+ :param check_uniqueness: whether or not to check that provided ``Node`` instances have unique IDs.
35
+ :return: a ``(NodeCollection, Edges)`` pair of ``hiveplotlib`` data structures.
36
+ """
37
+ node_data = []
38
+ for node, attributes in graph.nodes(data=True):
39
+ node_data.append({unique_id_name: node, **attributes})
40
+
41
+ node_df = pd.DataFrame(node_data)
42
+ edge_df = nx.to_pandas_edgelist(graph, source="from", target="to")
43
+ return NodeCollection(
44
+ data=node_df,
45
+ unique_id_column=unique_id_name,
46
+ check_uniqueness=check_uniqueness,
47
+ ), Edges(data=edge_df)
48
+
49
+
50
+ def nodes_edges_to_networkx(
51
+ nodes: NodeCollection,
52
+ edges: Edges,
53
+ *,
54
+ directed: bool = True,
55
+ multigraph: bool = True,
56
+ tag_attribute_name: str = "tag",
57
+ source_attribute_name: Optional[str] = None,
58
+ ) -> nx.Graph:
59
+ """
60
+ Convert a (``NodeCollection``, ``Edges``) pair to a ``networkx`` graph.
61
+
62
+ The concrete return type is determined by ``directed`` and ``multigraph``:
63
+
64
+ - ``directed=True``, ``multigraph=True`` → :py:class:`networkx.MultiDiGraph` (default).
65
+ - ``directed=True``, ``multigraph=False`` → :py:class:`networkx.DiGraph`.
66
+ - ``directed=False``, ``multigraph=True`` → :py:class:`networkx.MultiGraph`.
67
+ - ``directed=False``, ``multigraph=False`` → :py:class:`networkx.Graph`.
68
+
69
+ The defaults preserve duplicate edges faithfully and assume directed edges.
70
+
71
+ All non-(from / to) ``Edges`` DataFrame columns become edge attributes on the resulting graph. All
72
+ non-``unique_id_column`` node DataFrame columns become node attributes. The visualization-only attributes
73
+ ``node_viz_kwargs`` / ``edge_viz_kwargs`` are *not* included.
74
+
75
+ Multi-tag :py:class:`hiveplotlib.Edges`: when more than one tag is present, the original tag is written as an edge
76
+ attribute under ``tag_attribute_name`` (default ``"tag"``). If that name collides with an existing column on any
77
+ tag's edge DataFrame, a :class:`ValueError` is raised. Single-tag input does not write a tag attribute.
78
+
79
+ Optional source-row annotation: pass a string for ``source_attribute_name`` to tag each edge with a
80
+ ``(tag, row_index)`` tuple pointing back to its source row in the input :py:class:`hiveplotlib.Edges`. This is
81
+ useful for joining graph-level computations (e.g. edge metrics) back onto the original edge DataFrame (including
82
+ when there are multiple parallel edges in a multigraph). Default ``None`` skips this annotation.
83
+
84
+ .. note::
85
+ When ``multigraph=False`` but duplicate ``(from, to)`` pairs exist, ``networkx``'s :py:class:`networkx.Graph` /
86
+ :py:class:`networkx.DiGraph` will silently merge duplicates (last write wins). For an undirected
87
+ :py:class:`networkx.Graph`, reciprocal ``(a, b)`` / ``(b, a)`` rows likewise merge into a single undirected edge
88
+ (last write wins), so the merged edge carries only the surviving row's attributes (e.g. a ``weight``). Build
89
+ with ``multigraph=True`` to retain both edges as parallel edges, or pre-aggregate the weights into a single edge
90
+ beforehand.
91
+
92
+ :param nodes: :py:class:`hiveplotlib.NodeCollection` of node data.
93
+ :param edges: :py:class:`hiveplotlib.Edges` of edge data (single-tag or multi-tag).
94
+ :param directed: whether to return a :py:class:`networkx.DiGraph`-family graph. Default ``True``.
95
+ :param multigraph: whether to return a ``Multi*``-family graph. Default ``True``.
96
+ :param tag_attribute_name: edge-attribute name to use when storing the original tag on multi-tag inputs. Default
97
+ ``"tag"``.
98
+ :param source_attribute_name: optional edge-attribute name under which to store a ``(tag, row_index)`` source-row
99
+ identifier for every edge, useful for joining graph-level computations back onto the original edge DataFrame.
100
+ Default ``None`` skips annotation.
101
+ :return: ``networkx`` graph (one of :py:class:`networkx.Graph`, :py:class:`networkx.DiGraph`,
102
+ :py:class:`networkx.MultiGraph`, or :py:class:`networkx.MultiDiGraph`).
103
+ :raises ValueError: if ``tag_attribute_name`` collides with an existing edge column on a multi-tag
104
+ :py:class:`hiveplotlib.Edges` instance.
105
+ :raises ValueError: if ``source_attribute_name`` is a string and collides with an existing edge column on any tag.
106
+ """
107
+ if directed and multigraph:
108
+ graph_class = nx.MultiDiGraph
109
+ elif directed:
110
+ graph_class = nx.DiGraph
111
+ elif multigraph:
112
+ graph_class = nx.MultiGraph
113
+ else:
114
+ graph_class = nx.Graph
115
+ g = graph_class()
116
+
117
+ unique_id_column = nodes.unique_id_column
118
+ node_attr_cols = [c for c in nodes.data.columns if c != unique_id_column]
119
+ if node_attr_cols:
120
+ attr_records = nodes.data[node_attr_cols].to_dict(orient="records")
121
+ g.add_nodes_from(zip(nodes.data[unique_id_column], attr_records, strict=True))
122
+ else:
123
+ g.add_nodes_from(nodes.data[unique_id_column])
124
+
125
+ from_col = edges.from_column_name
126
+ to_col = edges.to_column_name
127
+ multi_tag = len(edges._data) > 1
128
+
129
+ if multi_tag:
130
+ for tag, df in edges._data.items():
131
+ if tag_attribute_name in df.columns:
132
+ msg = (
133
+ f"Cannot write tag attribute under name '{tag_attribute_name}' "
134
+ f"because tag '{tag}' already has a column with that name. "
135
+ "Pass `tag_attribute_name='<new_name>'` to choose a different "
136
+ "attribute name."
137
+ )
138
+ raise ValueError(msg)
139
+
140
+ if source_attribute_name is not None:
141
+ for tag, df in edges._data.items():
142
+ if source_attribute_name in df.columns:
143
+ msg = (
144
+ f"Cannot write source attribute under name '{source_attribute_name}' "
145
+ f"because tag '{tag}' already has a column with that name. "
146
+ "Pass `source_attribute_name='<new_name>'` to choose a different "
147
+ "attribute name."
148
+ )
149
+ raise ValueError(msg)
150
+
151
+ for tag, df in edges._data.items():
152
+ edge_attr_cols = [c for c in df.columns if c not in (from_col, to_col)]
153
+ attr_records = (
154
+ df[edge_attr_cols].to_dict(orient="records")
155
+ if edge_attr_cols
156
+ else [{} for _ in range(len(df))]
157
+ )
158
+ if multi_tag:
159
+ for attrs in attr_records:
160
+ attrs[tag_attribute_name] = tag
161
+ if source_attribute_name is not None:
162
+ for attrs, row_index in zip(attr_records, df.index, strict=True):
163
+ attrs[source_attribute_name] = (tag, row_index)
164
+ g.add_edges_from(zip(df[from_col], df[to_col], attr_records, strict=True))
165
+
166
+ return g
@@ -21,7 +21,7 @@ def international_trade_data(
21
21
  roughly 300mb. However, the raw data are available at the
22
22
  `Harvard Growth Lab's website <https://doi.org/10.7910/DVN/T4CHWJ>`_, and the runner to produce the necessary
23
23
  files to use this reader function is available in the
24
- `repository <https://gitlab.com/geomdata/hiveplotlib/-/blob/master/runners/make_trade_network_dataset.py>`_
24
+ `repository <https://gitlab.com/hiveplotlib/hiveplotlib/-/blob/master/runners/make_trade_network_dataset.py>`_
25
25
  (``make_trade_network_dataset.py``).
26
26
 
27
27
  If you are using the runner to make your own trade datasets that you will read in locally with this