hiveplotlib 0.26.2__tar.gz → 0.28.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.
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/LICENSE +2 -2
- {hiveplotlib-0.26.2/src/hiveplotlib.egg-info → hiveplotlib-0.28.0}/PKG-INFO +37 -25
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/README.md +14 -9
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/pyproject.toml +38 -17
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/__init__.py +4 -1
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/axis.py +4 -1
- hiveplotlib-0.28.0/src/hiveplotlib/converters.py +166 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/datasets/international_trade.py +2 -2
- hiveplotlib-0.28.0/src/hiveplotlib/datasets/toy_hive_plots.py +700 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/datasets/toy_p2cps.py +2 -2
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_metadata_2019_8112.json +1 -1
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/edges.py +56 -23
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/exceptions/hive_plot.py +11 -0
- hiveplotlib-0.28.0/src/hiveplotlib/graph_features/__init__.py +858 -0
- hiveplotlib-0.28.0/src/hiveplotlib/graph_features/networkx/__init__.py +103 -0
- hiveplotlib-0.28.0/src/hiveplotlib/graph_features/networkx/_helpers.py +177 -0
- hiveplotlib-0.28.0/src/hiveplotlib/graph_features/networkx/edge_metrics.py +259 -0
- hiveplotlib-0.28.0/src/hiveplotlib/graph_features/networkx/node_metrics.py +913 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/hiveplot.py +1086 -490
- hiveplotlib-0.28.0/src/hiveplotlib/hiveplot_matrix.py +2274 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/node.py +26 -13
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/p2cp.py +20 -17
- hiveplotlib-0.28.0/src/hiveplotlib/utils.py +316 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/base.py +16 -5
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/bokeh.py +15 -15
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/datashader.py +106 -49
- hiveplotlib-0.28.0/src/hiveplotlib/viz/hiveplot_matrix.py +657 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/holoviews.py +12 -12
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/matplotlib.py +8 -7
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/plotly.py +37 -22
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0/src/hiveplotlib.egg-info}/PKG-INFO +37 -25
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib.egg-info/SOURCES.txt +7 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib.egg-info/requires.txt +20 -11
- hiveplotlib-0.26.2/src/hiveplotlib/converters.py +0 -41
- hiveplotlib-0.26.2/src/hiveplotlib/datasets/toy_hive_plots.py +0 -331
- hiveplotlib-0.26.2/src/hiveplotlib/utils.py +0 -96
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/MANIFEST.in +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/setup.cfg +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/setup.py +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/datasets/__init__.py +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_2019_8112.csv +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/exceptions/__init__.py +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/exceptions/node.py +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/__init__.py +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib/viz/input_checks.py +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib.egg-info/dependency_links.txt +0 -0
- {hiveplotlib-0.26.2 → hiveplotlib-0.28.0}/src/hiveplotlib.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2020 -
|
|
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
|
|
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,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hiveplotlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.0
|
|
4
4
|
Summary: Visualize Network Data with Hive Plots
|
|
5
|
-
Author-email: Gary Koplik <gary.koplik@
|
|
6
|
-
License: Copyright (c) 2020 -
|
|
5
|
+
Author-email: Gary Koplik <gary.koplik@gmail.com>
|
|
6
|
+
License: Copyright (c) 2020 - 2026, Gary Koplik
|
|
7
7
|
All rights reserved.
|
|
8
8
|
|
|
9
9
|
Redistribution and use in source and binary forms, with or without modification,
|
|
@@ -16,7 +16,7 @@ License: Copyright (c) 2020 - 2024, Geometric Data Analytics, Inc.
|
|
|
16
16
|
this list of conditions and the following disclaimer in the documentation
|
|
17
17
|
and/or other materials provided with the distribution.
|
|
18
18
|
|
|
19
|
-
Neither the name of
|
|
19
|
+
Neither the name of Gary Koplik nor the names of any contributors
|
|
20
20
|
may be used to endorse or promote products derived from this software
|
|
21
21
|
without specific prior written permission.
|
|
22
22
|
|
|
@@ -33,7 +33,7 @@ License: Copyright (c) 2020 - 2024, Geometric Data Analytics, Inc.
|
|
|
33
33
|
THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
34
|
|
|
35
35
|
Project-URL: Documentation, https://hiveplotlib.readthedocs.io/stable/
|
|
36
|
-
Project-URL: Source, https://gitlab.com/
|
|
36
|
+
Project-URL: Source, https://gitlab.com/hiveplotlib/hiveplotlib
|
|
37
37
|
Requires-Python: >=3.10
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
39
|
License-File: LICENSE
|
|
@@ -41,28 +41,28 @@ Requires-Dist: matplotlib
|
|
|
41
41
|
Requires-Dist: numpy
|
|
42
42
|
Requires-Dist: pandas
|
|
43
43
|
Provides-Extra: bokeh
|
|
44
|
-
Requires-Dist: bokeh; extra == "bokeh"
|
|
44
|
+
Requires-Dist: bokeh>=3.0.0; extra == "bokeh"
|
|
45
45
|
Provides-Extra: datashader
|
|
46
46
|
Requires-Dist: dask[dataframe]; extra == "datashader"
|
|
47
47
|
Requires-Dist: datashader; extra == "datashader"
|
|
48
48
|
Requires-Dist: numba>0.54.0; extra == "datashader"
|
|
49
49
|
Requires-Dist: seaborn; extra == "datashader"
|
|
50
50
|
Provides-Extra: dev
|
|
51
|
-
Requires-Dist: bokeh; extra == "dev"
|
|
52
51
|
Requires-Dist: cartopy; extra == "dev"
|
|
53
|
-
Requires-Dist: dask[dataframe]; extra == "dev"
|
|
54
|
-
Requires-Dist: datashader; extra == "dev"
|
|
55
52
|
Requires-Dist: flexitext; extra == "dev"
|
|
56
53
|
Requires-Dist: geopandas; extra == "dev"
|
|
57
|
-
Requires-Dist:
|
|
54
|
+
Requires-Dist: hiveplotlib[bokeh]; extra == "dev"
|
|
55
|
+
Requires-Dist: hiveplotlib[datashader]; extra == "dev"
|
|
56
|
+
Requires-Dist: hiveplotlib[holoviews]; extra == "dev"
|
|
57
|
+
Requires-Dist: hiveplotlib[networkx]; extra == "dev"
|
|
58
|
+
Requires-Dist: hiveplotlib[plotly]; extra == "dev"
|
|
59
|
+
Requires-Dist: holoviews>=1.15; extra == "dev"
|
|
58
60
|
Requires-Dist: jupyter; extra == "dev"
|
|
59
|
-
Requires-Dist:
|
|
60
|
-
Requires-Dist: numba>0.54.0; extra == "dev"
|
|
61
|
-
Requires-Dist: plotly; extra == "dev"
|
|
61
|
+
Requires-Dist: nx-parallel; extra == "dev"
|
|
62
62
|
Requires-Dist: pybadges; extra == "dev"
|
|
63
|
-
Requires-Dist: seaborn; extra == "dev"
|
|
64
63
|
Requires-Dist: tqdm; extra == "dev"
|
|
65
64
|
Provides-Extra: docs
|
|
65
|
+
Requires-Dist: ipywidgets; extra == "docs"
|
|
66
66
|
Requires-Dist: myst-parser; extra == "docs"
|
|
67
67
|
Requires-Dist: nbsphinx; extra == "docs"
|
|
68
68
|
Requires-Dist: pydata-sphinx-theme; extra == "docs"
|
|
@@ -70,11 +70,16 @@ Requires-Dist: sphinx; extra == "docs"
|
|
|
70
70
|
Requires-Dist: sphinx-copybutton; extra == "docs"
|
|
71
71
|
Requires-Dist: toml; extra == "docs"
|
|
72
72
|
Provides-Extra: holoviews
|
|
73
|
-
Requires-Dist: bokeh; extra == "holoviews"
|
|
74
|
-
Requires-Dist: holoviews; extra == "holoviews"
|
|
73
|
+
Requires-Dist: bokeh>=3.0.0; extra == "holoviews"
|
|
74
|
+
Requires-Dist: holoviews>=1.15; extra == "holoviews"
|
|
75
75
|
Requires-Dist: numba>0.54.0; extra == "holoviews"
|
|
76
76
|
Provides-Extra: networkx
|
|
77
77
|
Requires-Dist: networkx; extra == "networkx"
|
|
78
|
+
Requires-Dist: scipy; extra == "networkx"
|
|
79
|
+
Provides-Extra: perf
|
|
80
|
+
Requires-Dist: pyinstrument; extra == "perf"
|
|
81
|
+
Requires-Dist: snakeviz; extra == "perf"
|
|
82
|
+
Requires-Dist: memory_profiler; extra == "perf"
|
|
78
83
|
Provides-Extra: plotly
|
|
79
84
|
Requires-Dist: plotly; extra == "plotly"
|
|
80
85
|
Provides-Extra: ruff
|
|
@@ -86,19 +91,22 @@ Requires-Dist: pytest-html; extra == "testing"
|
|
|
86
91
|
Requires-Dist: pytest-timeout; extra == "testing"
|
|
87
92
|
Requires-Dist: pytest-xdist; extra == "testing"
|
|
88
93
|
Requires-Dist: toml; extra == "testing"
|
|
94
|
+
Provides-Extra: ty
|
|
95
|
+
Requires-Dist: ty==0.0.20; extra == "ty"
|
|
89
96
|
Dynamic: license-file
|
|
90
97
|
|
|
91
98
|

|
|
92
99
|
|
|
93
100
|
A plotting package for generating and visualizing static Hive Plots in Python.
|
|
94
101
|
|
|
95
|
-

|
|
96
103
|
|
|
97
|
-
[](https://matplotlib.org/)
|
|
105
|
+
[](https://docs.bokeh.org/en/latest/)
|
|
106
|
+
[](https://holoviews.org/index.html)
|
|
107
|
+
[](https://plotly.com/python/)
|
|
108
|
+
[](https://datashader.org/)
|
|
109
|
+
[](https://networkx.org/)
|
|
102
110
|
|
|
103
111
|
# Installation
|
|
104
112
|
|
|
@@ -122,6 +130,10 @@ and [plotly](https://plotly.com/python/) visualizations, which can be installed
|
|
|
122
130
|
`hiveplotlib` also supports large network visualization via the [datashader](https://datashader.org/) backend,
|
|
123
131
|
which can be installed as `pip install hiveplotlib[datashader]`.
|
|
124
132
|
|
|
133
|
+
Beyond the visualization backends, `hiveplotlib` integrates with [networkx](https://networkx.org/): build a hive plot
|
|
134
|
+
directly from a `networkx` graph and compute graph metrics on it. Install this integration with
|
|
135
|
+
`pip install hiveplotlib[networkx]`.
|
|
136
|
+
|
|
125
137
|
# How to Use and Examples
|
|
126
138
|
|
|
127
139
|
For more on how to use the software and examples, see the
|
|
@@ -133,7 +145,7 @@ We recommend starting with our
|
|
|
133
145
|
[Quick Start Hive Plots](https://hiveplotlib.readthedocs.io/stable/notebooks/quick_hive_plots.html) pages.
|
|
134
146
|
|
|
135
147
|
All the example notebooks are available for download as `jupyter` notebooks in the repository under the
|
|
136
|
-
[examples](https://gitlab.com/
|
|
148
|
+
[examples](https://gitlab.com/hiveplotlib/hiveplotlib/-/tree/master/examples) directory.
|
|
137
149
|
|
|
138
150
|
To install this environment and associated `jupyter` kernel used to run the notebooks, clone the repository and run:
|
|
139
151
|
|
|
@@ -151,7 +163,7 @@ For more on Hive Plots, see our
|
|
|
151
163
|
|
|
152
164
|
For additional resources, see:
|
|
153
165
|
|
|
154
|
-
- [
|
|
166
|
+
- [https://hiveplot.com/](https://hiveplot.com/)
|
|
155
167
|
|
|
156
168
|
- Krzywinski M, Birol I, Jones S, Marra M (2011). Hive Plots — Rational Approach to
|
|
157
169
|
Visualizing Networks. Briefings in Bioinformatics (early access 9 December 2011,
|
|
@@ -159,7 +171,7 @@ doi: 10.1093/bib/bbr069).
|
|
|
159
171
|
|
|
160
172
|
# Contributing
|
|
161
173
|
|
|
162
|
-
For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/
|
|
174
|
+
For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/hiveplotlib/hiveplotlib/-/blob/master/CONTRIBUTING.md)
|
|
163
175
|
|
|
164
176
|
## Acknowledgements
|
|
165
177
|
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A plotting package for generating and visualizing static Hive Plots in Python.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
|
-
[](https://matplotlib.org/)
|
|
8
|
+
[](https://docs.bokeh.org/en/latest/)
|
|
9
|
+
[](https://holoviews.org/index.html)
|
|
10
|
+
[](https://plotly.com/python/)
|
|
11
|
+
[](https://datashader.org/)
|
|
12
|
+
[](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/
|
|
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
|
-
- [
|
|
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/
|
|
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,26 +7,26 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "hiveplotlib"
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
|
-
version = "0.
|
|
10
|
+
version = "0.28.0"
|
|
11
11
|
authors = [
|
|
12
|
-
{name="Gary Koplik", email="gary.koplik@
|
|
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
16
|
license = {file = "LICENSE"}
|
|
17
|
-
urls = {Documentation="https://hiveplotlib.readthedocs.io/stable/", Source="https://gitlab.com/
|
|
17
|
+
urls = {Documentation="https://hiveplotlib.readthedocs.io/stable/", Source="https://gitlab.com/hiveplotlib/hiveplotlib" }
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
dependencies = [
|
|
21
21
|
"matplotlib",
|
|
22
22
|
"numpy",
|
|
23
|
-
"pandas"
|
|
23
|
+
"pandas",
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
[project.optional-dependencies]
|
|
27
27
|
|
|
28
28
|
bokeh = [
|
|
29
|
-
"bokeh"
|
|
29
|
+
"bokeh>=3.0.0"
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
datashader = [
|
|
@@ -38,24 +38,24 @@ datashader = [
|
|
|
38
38
|
|
|
39
39
|
# developer dependencies
|
|
40
40
|
dev = [
|
|
41
|
-
"bokeh",
|
|
42
41
|
"cartopy",
|
|
43
|
-
"dask[dataframe]", # https://github.com/holoviz/datashader/issues/1319
|
|
44
|
-
"datashader",
|
|
45
42
|
"flexitext",
|
|
46
43
|
"geopandas",
|
|
47
|
-
"
|
|
44
|
+
"hiveplotlib[bokeh]",
|
|
45
|
+
"hiveplotlib[datashader]",
|
|
46
|
+
"hiveplotlib[holoviews]",
|
|
47
|
+
"hiveplotlib[networkx]",
|
|
48
|
+
"hiveplotlib[plotly]",
|
|
49
|
+
"holoviews>=1.15",
|
|
48
50
|
"jupyter",
|
|
49
|
-
"
|
|
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
|
|
|
57
56
|
# for building documentation
|
|
58
57
|
docs = [
|
|
58
|
+
"ipywidgets", # so nbsphinx can handle notebooks with widget metadata (e.g. tqdm progress bars)
|
|
59
59
|
"myst-parser",
|
|
60
60
|
"nbsphinx",
|
|
61
61
|
"pydata-sphinx-theme",
|
|
@@ -65,13 +65,21 @@ docs = [
|
|
|
65
65
|
]
|
|
66
66
|
|
|
67
67
|
holoviews = [
|
|
68
|
-
"bokeh",
|
|
69
|
-
"holoviews",
|
|
68
|
+
"bokeh>=3.0.0",
|
|
69
|
+
"holoviews>=1.15",
|
|
70
70
|
"numba>0.54.0", # https://github.com/numba/numba/issues/9708
|
|
71
71
|
]
|
|
72
72
|
|
|
73
73
|
networkx = [
|
|
74
|
-
"networkx"
|
|
74
|
+
"networkx",
|
|
75
|
+
"scipy", # for some graph feature computations
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
# performance profiling extras
|
|
79
|
+
perf = [
|
|
80
|
+
"pyinstrument",
|
|
81
|
+
"snakeviz",
|
|
82
|
+
"memory_profiler",
|
|
75
83
|
]
|
|
76
84
|
|
|
77
85
|
plotly = [
|
|
@@ -80,7 +88,7 @@ plotly = [
|
|
|
80
88
|
|
|
81
89
|
# ruff code hygeine checks
|
|
82
90
|
ruff = [
|
|
83
|
-
"ruff"
|
|
91
|
+
"ruff",
|
|
84
92
|
]
|
|
85
93
|
|
|
86
94
|
testing = [
|
|
@@ -92,10 +100,23 @@ testing = [
|
|
|
92
100
|
"toml",
|
|
93
101
|
]
|
|
94
102
|
|
|
103
|
+
# ty code hygeine checks
|
|
104
|
+
ty = [
|
|
105
|
+
"ty==0.0.20", # pinning for now, 0.0.21 would require non trivial type hint changes that affect the user
|
|
106
|
+
]
|
|
107
|
+
|
|
95
108
|
[tool.setuptools.packages.find]
|
|
96
109
|
where = ["src"]
|
|
97
110
|
include = ["hiveplotlib*"]
|
|
98
111
|
|
|
112
|
+
[tool.ty.src]
|
|
113
|
+
exclude = [
|
|
114
|
+
"docs",
|
|
115
|
+
"examples",
|
|
116
|
+
"runners",
|
|
117
|
+
"sandbox",
|
|
118
|
+
]
|
|
119
|
+
|
|
99
120
|
[tool.ruff]
|
|
100
121
|
# ruff performs our linting and formatting.
|
|
101
122
|
# if you receive an error you don't understand, you can run `ruff rule <error code>` to learn more.
|
|
@@ -10,7 +10,10 @@ from hiveplotlib.hiveplot import ( # noqa: F401
|
|
|
10
10
|
SUPPORTED_VIZ_BACKENDS,
|
|
11
11
|
BaseHivePlot,
|
|
12
12
|
HivePlot,
|
|
13
|
-
|
|
13
|
+
)
|
|
14
|
+
from hiveplotlib.hiveplot_matrix import ( # noqa: F401
|
|
15
|
+
HPM_SUPPORTED_VIZ_BACKENDS,
|
|
16
|
+
HivePlotMatrix,
|
|
14
17
|
)
|
|
15
18
|
from hiveplotlib.node import Node, NodeCollection # noqa: F401
|
|
16
19
|
from hiveplotlib.p2cp import P2CP, p2cp_n_axes # noqa: F401
|
|
@@ -6,6 +6,7 @@ Definition of ``Axis`` instance and helper static methods for generating and wor
|
|
|
6
6
|
|
|
7
7
|
from typing import Hashable, Optional
|
|
8
8
|
|
|
9
|
+
import numpy as np
|
|
9
10
|
import pandas as pd
|
|
10
11
|
|
|
11
12
|
from hiveplotlib.utils import polar2cartesian
|
|
@@ -93,7 +94,9 @@ class Axis:
|
|
|
93
94
|
self.sorting_variable = None
|
|
94
95
|
|
|
95
96
|
# hold all the cartesian coordinates, polar rho, corresponding labels, and node metadata in a pandas dataframe
|
|
96
|
-
self.node_placements = pd.DataFrame(
|
|
97
|
+
self.node_placements = pd.DataFrame(
|
|
98
|
+
columns=np.array(["x", "y", "unique_id", "rho"])
|
|
99
|
+
)
|
|
97
100
|
|
|
98
101
|
# hold the current vmin and vmax used to place nodes on an axis in a ``HivePlot`` instance.
|
|
99
102
|
self.vmin = None
|
|
@@ -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/
|
|
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
|
|
@@ -52,7 +52,7 @@ def international_trade_data(
|
|
|
52
52
|
csv_years = [i.split("_")[2] for i in csv_files]
|
|
53
53
|
csv_hs92 = [i.split("_")[-1] for i in csv_files]
|
|
54
54
|
hiveplotlib_supported_values = pd.DataFrame(
|
|
55
|
-
np.c_[csv_years, csv_hs92], columns=["Year", "Trade Code"]
|
|
55
|
+
np.c_[csv_years, csv_hs92], columns=np.array(["Year", "Trade Code"])
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
# check that our implied data and metadata files exist
|