hiveplotlib 0.22.0__tar.gz → 0.23.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {hiveplotlib-0.22.0/src/hiveplotlib.egg-info → hiveplotlib-0.23.0}/PKG-INFO +3 -1
  2. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/pyproject.toml +7 -4
  3. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/datasets/__init__.py +7 -2
  4. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/hiveplot.py +7 -0
  5. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/utils.py +2 -6
  6. hiveplotlib-0.23.0/src/hiveplotlib/viz/base.py +61 -0
  7. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/viz/bokeh.py +170 -243
  8. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/viz/datashader.py +18 -37
  9. hiveplotlib-0.23.0/src/hiveplotlib/viz/input_checks.py +99 -0
  10. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/viz/matplotlib.py +172 -222
  11. hiveplotlib-0.23.0/src/hiveplotlib/viz/plotly.py +822 -0
  12. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0/src/hiveplotlib.egg-info}/PKG-INFO +3 -1
  13. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib.egg-info/SOURCES.txt +3 -1
  14. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib.egg-info/requires.txt +3 -0
  15. hiveplotlib-0.22.0/src/hiveplotlib/viz/input_checks.py +0 -30
  16. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/LICENSE +0 -0
  17. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/MANIFEST.in +0 -0
  18. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/README.md +0 -0
  19. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/setup.cfg +0 -0
  20. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/setup.py +0 -0
  21. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/__init__.py +0 -0
  22. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/axis.py +0 -0
  23. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/converters.py +0 -0
  24. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_2019_8112.csv +0 -0
  25. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_metadata_2019_8112.json +0 -0
  26. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/node.py +0 -0
  27. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/p2cp.py +0 -0
  28. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib/viz/__init__.py +0 -0
  29. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib.egg-info/dependency_links.txt +0 -0
  30. {hiveplotlib-0.22.0 → hiveplotlib-0.23.0}/src/hiveplotlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hiveplotlib
3
- Version: 0.22.0
3
+ Version: 0.23.0
4
4
  Summary: Visualize Network Data with Hive Plots
5
5
  Author-email: Gary Koplik <gary.koplik@geomdata.com>
6
6
  License: Copyright (c) 2020 - 2023, Geometric Data Analytics, Inc.
@@ -57,6 +57,8 @@ Requires-Dist: sphinx-rtd-theme; extra == "docs"
57
57
  Requires-Dist: toml; extra == "docs"
58
58
  Provides-Extra: networkx
59
59
  Requires-Dist: networkx; extra == "networkx"
60
+ Provides-Extra: plotly
61
+ Requires-Dist: plotly; extra == "plotly"
60
62
  Provides-Extra: testing
61
63
  Requires-Dist: black[jupyter]; extra == "testing"
62
64
  Requires-Dist: flake8-docstrings; extra == "testing"
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "hiveplotlib"
10
- version = "0.22.0"
10
+ version = "0.23.0"
11
11
  authors = [
12
12
  {name="Gary Koplik", email="gary.koplik@geomdata.com"}
13
13
  ]
@@ -54,6 +54,10 @@ networkx = [
54
54
  "networkx"
55
55
  ]
56
56
 
57
+ plotly = [
58
+ "plotly"
59
+ ]
60
+
57
61
  testing = [
58
62
  "black[jupyter]",
59
63
  "flake8-docstrings",
@@ -85,10 +89,9 @@ exclude = [
85
89
  extend_ignore = [
86
90
  "D200", # 1-line docstrings will be tolerated
87
91
  "E203", # https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated
88
- "E501", # can't check line-length and have long hyperlinks in the docs
89
92
  "W503" # docs literally say this should not be a thing https://www.flake8rules.com/rules/W504.html
90
93
  ]
91
- # skipping any line length checks because of long hyperlink docstring lines.
92
- color = "always"
94
+ # keeping a longer-allowed line-length on flake8 side for existing docs
95
+ max-line-length = 120
93
96
  show-source = true
94
97
  count = true
@@ -147,7 +147,10 @@ def four_gaussian_blobs_3d(
147
147
 
148
148
 
149
149
  def example_hive_plot(
150
- num_nodes: int = 15, num_edges: int = 30, seed: int = 0
150
+ num_nodes: int = 15,
151
+ num_edges: int = 30,
152
+ seed: int = 0,
153
+ **hive_plot_n_axes_kwargs,
151
154
  ) -> HivePlot:
152
155
  """
153
156
  Generate example hive plot with ``"Low"``, ``"Medium"``, and ``"High"`` axes (plus repeat axes).
@@ -157,6 +160,8 @@ def example_hive_plot(
157
160
  :param num_nodes: number of nodes to generate.
158
161
  :param num_edges: number of edges to generate.
159
162
  :param seed: random seed to use when generating nodes and edges.
163
+ :param hive_plot_n_axes_kwargs: additional keyword arguments for the underlying
164
+ :py:func:`hiveplotlib.hive_plot.hive_plot_n_axes()` call.
160
165
  :return: resulting ``HivePlot`` instance.
161
166
  """
162
167
  color_dict = {
@@ -202,7 +207,7 @@ def example_hive_plot(
202
207
  repeat_axes=[True, True, True],
203
208
  axes_names=["Low", "Medium", "High"],
204
209
  orient_angle=-30,
205
- all_edge_kwargs=dict(alpha=1),
210
+ **hive_plot_n_axes_kwargs,
206
211
  )
207
212
 
208
213
  # set colors according to above-defined color dictionary
@@ -52,6 +52,9 @@ class HivePlot:
52
52
  # maintain dictionary of dictionaries of dictionaries of edge information
53
53
  self.edges = dict()
54
54
 
55
+ # maintain the largest polar end point from the axes (for plotting)
56
+ self.max_polar_end = None
57
+
55
58
  def add_axes(self, axes: List[Axis]):
56
59
  """
57
60
  Add list of ``Axis`` instances to ``HivePlot.axes``.
@@ -72,6 +75,10 @@ class HivePlot:
72
75
  for axis in axes:
73
76
  self.axes[axis.axis_id] = axis
74
77
  self.node_assignments[axis.axis_id] = None
78
+
79
+ # update overall largest max polar end point
80
+ self.max_polar_end = max([axis.polar_end for axis in self.axes.values()])
81
+
75
82
  return None
76
83
 
77
84
  def add_nodes(self, nodes: List[Node], check_uniqueness: bool = True):
@@ -59,9 +59,7 @@ def bezier(
59
59
  :return: ``(num_steps, )`` sized ``np.ndarray`` of 1-dimensional discretized Bézier curve output.
60
60
  """
61
61
  steps = np.linspace(0, 1, num_steps)
62
- return (
63
- (1 - steps) ** 2 * start + 2 * (1 - steps) * steps * control + steps**2 * end
64
- )
62
+ return (1 - steps) ** 2 * start + 2 * (1 - steps) * steps * control + steps**2 * end
65
63
 
66
64
 
67
65
  def bezier_all(
@@ -94,6 +92,4 @@ def bezier_all(
94
92
  end = np.repeat(end_arr, num_steps)
95
93
  control = np.repeat(control_arr, num_steps)
96
94
 
97
- return (
98
- (1 - steps) ** 2 * start + 2 * (1 - steps) * steps * control + steps**2 * end
99
- )
95
+ return (1 - steps) ** 2 * start + 2 * (1 - steps) * steps * control + steps**2 * end
@@ -0,0 +1,61 @@
1
+ # base.py
2
+
3
+ """
4
+ Base (viz back-end-agnostic) functionality for visualizations in ``hiveplotlib``.
5
+ """
6
+
7
+ from hiveplotlib import Axis
8
+ from typing import Literal, Tuple
9
+
10
+
11
+ def get_axis_label_alignment(
12
+ axis: Axis,
13
+ backend: Literal = ["matplotlib", "bokeh", "plotly"],
14
+ horizontal_angle_span: float = 60,
15
+ vertical_angle_span: float = 60,
16
+ ) -> Tuple[Literal["bottom", "middle", "top"], Literal["left", "center", "right"]]:
17
+ """
18
+ Generate appropriate horizontal and vertical alignment for text at the radial end point of an ``Axis`` instance.
19
+
20
+ ``horizontal_angle_span`` and ``vertical_angle_span`` dictate the text alignment partition, measured in degrees. See
21
+ the below parameter descriptions for how each value is used to partition the angle space.
22
+
23
+ :param axis: ``Axis`` for which to generate the appropriate text alignment.
24
+ :param backend: which plotting back end to use. (Different back ends have different string names for their
25
+ alignment options.)
26
+ :param horizontal_angle_span: ``[-horizontal_angle_span, horizontal_angle_span]`` will be ``"left"`` aligned.
27
+ ``[180 - horizontal_angle_span, 180 + horizontal_angle_span]`` will be ``right`` aligned, and all other angles
28
+ will be ``"center"`` aligned.
29
+ :param vertical_angle_span: ``[90 - vertical_angle_span, 90 + vertical_angle_span]`` will be ``"bottom"`` aligned.
30
+ ``[270 - vertical_angle_span, 270 + vertical_angle_span]`` will be ``top`` aligned, and all other angles
31
+ will be ``"middle"`` aligned.
32
+ :return: vertical alignment string and horizontal alignment string appropriate for the edge of the provided
33
+ ``Axis`` instance.
34
+ """
35
+ horizontal_alignment_dict = dict(left="left", center="center", right="right")
36
+ vertical_alignment_dict = dict(bottom="bottom", middle="middle", top="top")
37
+
38
+ # matplotlib has different naming convention than default
39
+ if backend == "matplotlib":
40
+ vertical_alignment_dict["middle"] = "center"
41
+
42
+ # range in each direction from 0, 180 to specify horizontal alignment
43
+ if (
44
+ axis.angle >= 360 - horizontal_angle_span
45
+ or axis.angle <= 0 + horizontal_angle_span
46
+ ):
47
+ horizontalalignment = horizontal_alignment_dict["left"]
48
+ elif 180 + horizontal_angle_span >= axis.angle >= 180 - horizontal_angle_span:
49
+ horizontalalignment = horizontal_alignment_dict["right"]
50
+ else:
51
+ horizontalalignment = horizontal_alignment_dict["center"]
52
+
53
+ # range in each direction from 90, 270 to specify vertical alignment
54
+ if 90 + vertical_angle_span >= axis.angle >= 90 - vertical_angle_span:
55
+ verticalalignment = vertical_alignment_dict["bottom"]
56
+ elif 270 - vertical_angle_span <= axis.angle <= 270 + vertical_angle_span:
57
+ verticalalignment = vertical_alignment_dict["top"]
58
+ else:
59
+ verticalalignment = vertical_alignment_dict["middle"]
60
+
61
+ return verticalalignment, horizontalalignment