risk-network 0.0.8b18__py3-none-any.whl → 0.0.8b20__py3-none-any.whl

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.
@@ -34,8 +34,8 @@ class Canvas:
34
34
  title_fontsize: int = 20,
35
35
  subtitle_fontsize: int = 14,
36
36
  font: str = "Arial",
37
- title_color: Union[str, list, tuple, np.ndarray] = "black",
38
- subtitle_color: Union[str, list, tuple, np.ndarray] = "gray",
37
+ title_color: Union[str, List, Tuple, np.ndarray] = "black",
38
+ subtitle_color: Union[str, List, Tuple, np.ndarray] = "gray",
39
39
  title_y: float = 0.975,
40
40
  title_space_offset: float = 0.075,
41
41
  subtitle_offset: float = 0.025,
@@ -48,9 +48,9 @@ class Canvas:
48
48
  title_fontsize (int, optional): Font size for the title. Defaults to 20.
49
49
  subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to 14.
50
50
  font (str, optional): Font family used for both title and subtitle. Defaults to "Arial".
51
- title_color (str, list, tuple, or np.ndarray, optional): Color of the title text. Can be a string or an array of colors.
51
+ title_color (str, List, Tuple, or np.ndarray, optional): Color of the title text. Can be a string or an array of colors.
52
52
  Defaults to "black".
53
- subtitle_color (str, list, tuple, or np.ndarray, optional): Color of the subtitle text. Can be a string or an array of colors.
53
+ subtitle_color (str, List, Tuple, or np.ndarray, optional): Color of the subtitle text. Can be a string or an array of colors.
54
54
  Defaults to "gray".
55
55
  title_y (float, optional): Y-axis position of the title. Defaults to 0.975.
56
56
  title_space_offset (float, optional): Fraction of figure height to leave for the space above the plot. Defaults to 0.075.
@@ -124,7 +124,7 @@ class Canvas:
124
124
  scale (float, optional): Scaling factor for the perimeter diameter. Defaults to 1.0.
125
125
  linestyle (str, optional): Line style for the network perimeter circle (e.g., dashed, solid). Defaults to "dashed".
126
126
  linewidth (float, optional): Width of the circle's outline. Defaults to 1.5.
127
- color (str, list, tuple, or np.ndarray, optional): Color of the network perimeter circle. Defaults to "black".
127
+ color (str, List, Tuple, or np.ndarray, optional): Color of the network perimeter circle. Defaults to "black".
128
128
  outline_alpha (float, None, optional): Transparency level of the circle outline. If provided, it overrides any existing alpha
129
129
  values found in color. Defaults to 1.0.
130
130
  fill_alpha (float, None, optional): Transparency level of the circle fill. If provided, it overrides any existing alpha values
@@ -137,7 +137,7 @@ class Canvas:
137
137
  perimeter_linestyle=linestyle,
138
138
  perimeter_linewidth=linewidth,
139
139
  perimeter_color=(
140
- "custom" if isinstance(color, (list, tuple, np.ndarray)) else color
140
+ "custom" if isinstance(color, (List, Tuple, np.ndarray)) else color
141
141
  ), # np.ndarray usually indicates custom colors
142
142
  perimeter_outline_alpha=outline_alpha,
143
143
  perimeter_fill_alpha=fill_alpha,
@@ -193,7 +193,7 @@ class Canvas:
193
193
  levels (int, optional): Number of contour levels. Defaults to 3.
194
194
  bandwidth (float, optional): Bandwidth for the KDE. Controls smoothness. Defaults to 0.8.
195
195
  grid_size (int, optional): Grid resolution for the KDE. Higher values yield finer contours. Defaults to 250.
196
- color (str, list, tuple, or np.ndarray, optional): Color of the network perimeter contour. Defaults to "black".
196
+ color (str, List, Tuple, or np.ndarray, optional): Color of the network perimeter contour. Defaults to "black".
197
197
  linestyle (str, optional): Line style for the network perimeter contour (e.g., dashed, solid). Defaults to "solid".
198
198
  linewidth (float, optional): Width of the contour's outline. Defaults to 1.5.
199
199
  outline_alpha (float, None, optional): Transparency level of the contour outline. If provided, it overrides any existing
@@ -210,7 +210,7 @@ class Canvas:
210
210
  perimeter_grid_size=grid_size,
211
211
  perimeter_linestyle=linestyle,
212
212
  perimeter_linewidth=linewidth,
213
- perimeter_color=("custom" if isinstance(color, (list, tuple, np.ndarray)) else color),
213
+ perimeter_color=("custom" if isinstance(color, (List, Tuple, np.ndarray)) else color),
214
214
  perimeter_outline_alpha=outline_alpha,
215
215
  perimeter_fill_alpha=fill_alpha,
216
216
  )
@@ -46,7 +46,7 @@ class Contour:
46
46
  levels (int, optional): Number of contour levels to plot. Defaults to 5.
47
47
  bandwidth (float, optional): Bandwidth for KDE. Controls the smoothness of the contour. Defaults to 0.8.
48
48
  grid_size (int, optional): Resolution of the grid for KDE. Higher values create finer contours. Defaults to 250.
49
- color (str, list, tuple, or np.ndarray, optional): Color of the contours. Can be a single color or an array of colors.
49
+ color (str, List, Tuple, or np.ndarray, optional): Color of the contours. Can be a single color or an array of colors.
50
50
  Defaults to "white".
51
51
  linestyle (str, optional): Line style for the contours. Defaults to "solid".
52
52
  linewidth (float, optional): Line width for the contours. Defaults to 1.5.
@@ -105,11 +105,11 @@ class Contour:
105
105
  """Plot a subcontour for a given set of nodes or a list of node sets using Kernel Density Estimation (KDE).
106
106
 
107
107
  Args:
108
- nodes (list, tuple, or np.ndarray): List of node labels or list of lists of node labels to plot the contour for.
108
+ nodes (List, Tuple, or np.ndarray): List of node labels or list of lists of node labels to plot the contour for.
109
109
  levels (int, optional): Number of contour levels to plot. Defaults to 5.
110
110
  bandwidth (float, optional): Bandwidth for KDE. Controls the smoothness of the contour. Defaults to 0.8.
111
111
  grid_size (int, optional): Resolution of the grid for KDE. Higher values create finer contours. Defaults to 250.
112
- color (str, list, tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array.
112
+ color (str, List, Tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array.
113
113
  Can be a single color or an array of colors. Defaults to "white".
114
114
  linestyle (str, optional): Line style for the contour. Defaults to "solid".
115
115
  linewidth (float, optional): Line width for the contour. Defaults to 1.5.
@@ -122,7 +122,7 @@ class Contour:
122
122
  ValueError: If no valid nodes are found in the network graph.
123
123
  """
124
124
  # Check if nodes is a list of lists or a flat list
125
- if any(isinstance(item, (list, tuple, np.ndarray)) for item in nodes):
125
+ if any(isinstance(item, (List, Tuple, np.ndarray)) for item in nodes):
126
126
  # If it's a list of lists, iterate over sublists
127
127
  node_groups = nodes
128
128
  # Convert color to RGBA arrays to match the number of groups
@@ -181,7 +181,7 @@ class Contour:
181
181
  Args:
182
182
  ax (plt.Axes): The axis to draw the contour on.
183
183
  pos (np.ndarray): Array of node positions (x, y).
184
- nodes (list): List of node indices to include in the contour.
184
+ nodes (List): List of node indices to include in the contour.
185
185
  levels (int, optional): Number of contour levels. Defaults to 5.
186
186
  bandwidth (float, optional): Bandwidth for the KDE. Controls smoothness. Defaults to 0.8.
187
187
  grid_size (int, optional): Grid resolution for the KDE. Higher values yield finer contours. Defaults to 250.
@@ -274,7 +274,9 @@ class Contour:
274
274
  def get_annotated_contour_colors(
275
275
  self,
276
276
  cmap: str = "gist_rainbow",
277
- color: Union[str, list, tuple, np.ndarray, None] = None,
277
+ color: Union[str, List, Tuple, np.ndarray, None] = None,
278
+ blend_colors: bool = False,
279
+ blend_gamma: float = 2.2,
278
280
  min_scale: float = 0.8,
279
281
  max_scale: float = 1.0,
280
282
  scale_factor: float = 1.0,
@@ -284,8 +286,10 @@ class Contour:
284
286
 
285
287
  Args:
286
288
  cmap (str, optional): Name of the colormap to use for generating contour colors. Defaults to "gist_rainbow".
287
- color (str, list, tuple, np.ndarray, or None, optional): Color to use for the contours. Can be a single color or an array of colors.
289
+ color (str, List, Tuple, np.ndarray, or None, optional): Color to use for the contours. Can be a single color or an array of colors.
288
290
  If None, the colormap will be used. Defaults to None.
291
+ blend_colors (bool, optional): Whether to blend colors for nodes with multiple domains. Defaults to False.
292
+ blend_gamma (float, optional): Gamma correction factor for perceptual color blending. Defaults to 2.2.
289
293
  min_scale (float, optional): Minimum intensity scale for the colors generated by the colormap.
290
294
  Controls the dimmest colors. Defaults to 0.8.
291
295
  max_scale (float, optional): Maximum intensity scale for the colors generated by the colormap.
@@ -301,6 +305,8 @@ class Contour:
301
305
  graph=self.graph,
302
306
  cmap=cmap,
303
307
  color=color,
308
+ blend_colors=blend_colors,
309
+ blend_gamma=blend_gamma,
304
310
  min_scale=min_scale,
305
311
  max_scale=max_scale,
306
312
  scale_factor=scale_factor,
@@ -66,13 +66,13 @@ class Labels:
66
66
  - If a dictionary, maps specific cases ('lower', 'upper', 'title') to transformations (e.g., 'lower'='upper').
67
67
  - If None, no transformation is applied.
68
68
  fontsize (int, optional): Font size for the labels. Defaults to 10.
69
- fontcolor (str, list, tuple, or np.ndarray, optional): Color of the label text. Can be a string or RGBA array.
69
+ fontcolor (str, List, Tuple, or np.ndarray, optional): Color of the label text. Can be a string or RGBA array.
70
70
  Defaults to "black".
71
71
  fontalpha (float, None, optional): Transparency level for the font color. If provided, it overrides any existing alpha
72
72
  values found in fontcolor. Defaults to 1.0.
73
73
  arrow_linewidth (float, optional): Line width of the arrows pointing to centroids. Defaults to 1.
74
74
  arrow_style (str, optional): Style of the arrows pointing to centroids. Defaults to "->".
75
- arrow_color (str, list, tuple, or np.ndarray, optional): Color of the arrows. Defaults to "black".
75
+ arrow_color (str, List, Tuple, or np.ndarray, optional): Color of the arrows. Defaults to "black".
76
76
  arrow_alpha (float, None, optional): Transparency level for the arrow color. If provided, it overrides any existing alpha
77
77
  values found in arrow_color. Defaults to 1.0.
78
78
  arrow_base_shrink (float, optional): Distance between the text and the base of the arrow. Defaults to 0.0.
@@ -82,11 +82,11 @@ class Labels:
82
82
  max_label_lines (int, optional): Maximum number of lines in a label. Defaults to None (no limit).
83
83
  min_chars_per_line (int, optional): Minimum number of characters in a line to display. Defaults to 1.
84
84
  max_chars_per_line (int, optional): Maximum number of characters in a line to display. Defaults to None (no limit).
85
- words_to_omit (list, optional): List of words to omit from the labels. Defaults to None.
85
+ words_to_omit (List, optional): List of words to omit from the labels. Defaults to None.
86
86
  overlay_ids (bool, optional): Whether to overlay domain IDs in the center of the centroids. Defaults to False.
87
- ids_to_keep (list, tuple, np.ndarray, or None, optional): IDs of domains that must be labeled. To discover domain IDs,
87
+ ids_to_keep (List, Tuple, np.ndarray, or None, optional): IDs of domains that must be labeled. To discover domain IDs,
88
88
  you can set `overlay_ids=True`. Defaults to None.
89
- ids_to_replace (dict, optional): A dictionary mapping domain IDs to custom labels (strings). The labels should be
89
+ ids_to_replace (Dict, optional): A dictionary mapping domain IDs to custom labels (strings). The labels should be
90
90
  space-separated words. If provided, the custom labels will replace the default domain terms. To discover domain IDs, you
91
91
  can set `overlay_ids=True`. Defaults to None.
92
92
 
@@ -263,26 +263,26 @@ class Labels:
263
263
  """Annotate the network graph with a label for the given nodes, with one arrow pointing to each centroid of sublists of nodes.
264
264
 
265
265
  Args:
266
- nodes (list, tuple, or np.ndarray): List of node labels or list of lists of node labels.
266
+ nodes (List, Tuple, or np.ndarray): List of node labels or list of lists of node labels.
267
267
  label (str): The label to be annotated on the network.
268
268
  radial_position (float, optional): Radial angle for positioning the label, in degrees (0-360). Defaults to 0.0.
269
269
  scale (float, optional): Scale factor for positioning the label around the perimeter. Defaults to 1.05.
270
270
  offset (float, optional): Offset distance for the label from the perimeter. Defaults to 0.10.
271
271
  font (str, optional): Font name for the label. Defaults to "Arial".
272
272
  fontsize (int, optional): Font size for the label. Defaults to 10.
273
- fontcolor (str, list, tuple, or np.ndarray, optional): Color of the label text. Defaults to "black".
273
+ fontcolor (str, List, Tuple, or np.ndarray, optional): Color of the label text. Defaults to "black".
274
274
  fontalpha (float, None, optional): Transparency level for the font color. If provided, it overrides any existing alpha values found
275
275
  in fontalpha. Defaults to 1.0.
276
276
  arrow_linewidth (float, optional): Line width of the arrow pointing to the centroid. Defaults to 1.
277
277
  arrow_style (str, optional): Style of the arrows pointing to the centroid. Defaults to "->".
278
- arrow_color (str, list, tuple, or np.ndarray, optional): Color of the arrow. Defaults to "black".
278
+ arrow_color (str, List, Tuple, or np.ndarray, optional): Color of the arrow. Defaults to "black".
279
279
  arrow_alpha (float, None, optional): Transparency level for the arrow color. If provided, it overrides any existing alpha values
280
280
  found in arrow_alpha. Defaults to 1.0.
281
281
  arrow_base_shrink (float, optional): Distance between the text and the base of the arrow. Defaults to 0.0.
282
282
  arrow_tip_shrink (float, optional): Distance between the arrow tip and the centroid. Defaults to 0.0.
283
283
  """
284
284
  # Check if nodes is a list of lists or a flat list
285
- if any(isinstance(item, (list, tuple, np.ndarray)) for item in nodes):
285
+ if any(isinstance(item, (List, Tuple, np.ndarray)) for item in nodes):
286
286
  # If it's a list of lists, iterate over sublists
287
287
  node_groups = nodes
288
288
  # Convert fontcolor and arrow_color to RGBA arrays to match the number of groups
@@ -347,7 +347,7 @@ class Labels:
347
347
  """Calculate the most centrally located node in .
348
348
 
349
349
  Args:
350
- nodes (list): List of node labels to include in the subnetwork.
350
+ nodes (List): List of node labels to include in the subnetwork.
351
351
 
352
352
  Returns:
353
353
  tuple: A tuple containing the domain's central node coordinates.
@@ -382,18 +382,18 @@ class Labels:
382
382
  """Process the ids_to_keep, apply filtering, and store valid domain centroids and terms.
383
383
 
384
384
  Args:
385
- domain_id_to_centroid_map (dict): Mapping of domain IDs to their centroids.
386
- ids_to_keep (list, tuple, or np.ndarray, optional): IDs of domains that must be labeled.
387
- ids_to_replace (dict, optional): A dictionary mapping domain IDs to custom labels. Defaults to None.
388
- words_to_omit (list, optional): List of words to omit from the labels. Defaults to None.
385
+ domain_id_to_centroid_map (Dict[str, np.ndarray]): Mapping of domain IDs to their centroids.
386
+ ids_to_keep (List, Tuple, or np.ndarray, optional): IDs of domains that must be labeled.
387
+ ids_to_replace (Dict[str, str], optional): A dictionary mapping domain IDs to custom labels. Defaults to None.
388
+ words_to_omit (List, optional): List of words to omit from the labels. Defaults to None.
389
389
  max_labels (int, optional): Maximum number of labels allowed.
390
390
  min_label_lines (int): Minimum number of lines in a label.
391
391
  max_label_lines (int): Maximum number of lines in a label.
392
392
  min_chars_per_line (int): Minimum number of characters in a line to display.
393
393
  max_chars_per_line (int): Maximum number of characters in a line to display.
394
- filtered_domain_centroids (dict): Dictionary to store filtered domain centroids (output).
395
- filtered_domain_terms (dict): Dictionary to store filtered domain terms (output).
396
- valid_indices (list): List to store valid indices (output).
394
+ filtered_domain_centroids (Dict[str, np.ndarray]): Dictionary to store filtered domain centroids (output).
395
+ filtered_domain_terms (Dict[str, str]): Dictionary to store filtered domain terms (output).
396
+ valid_indices (List): List to store valid indices (output).
397
397
 
398
398
  Note:
399
399
  The `filtered_domain_centroids`, `filtered_domain_terms`, and `valid_indices` are modified in-place.
@@ -448,18 +448,18 @@ class Labels:
448
448
  """Process remaining domains to fill in additional labels, respecting the remaining_labels limit.
449
449
 
450
450
  Args:
451
- domain_id_to_centroid_map (dict): Mapping of domain IDs to their centroids.
452
- ids_to_keep (list, tuple, or np.ndarray, optional): IDs of domains that must be labeled.
453
- ids_to_replace (dict, optional): A dictionary mapping domain IDs to custom labels. Defaults to None.
454
- words_to_omit (list, optional): List of words to omit from the labels. Defaults to None.
451
+ domain_id_to_centroid_map (Dict[str, np.ndarray]): Mapping of domain IDs to their centroids.
452
+ ids_to_keep (List, Tuple, or np.ndarray, optional): IDs of domains that must be labeled.
453
+ ids_to_replace (Dict[str, str], optional): A dictionary mapping domain IDs to custom labels. Defaults to None.
454
+ words_to_omit (List, optional): List of words to omit from the labels. Defaults to None.
455
455
  remaining_labels (int): The remaining number of labels that can be generated.
456
456
  min_label_lines (int): Minimum number of lines in a label.
457
457
  max_label_lines (int): Maximum number of lines in a label.
458
458
  min_chars_per_line (int): Minimum number of characters in a line to display.
459
459
  max_chars_per_line (int): Maximum number of characters in a line to display.
460
- filtered_domain_centroids (dict): Dictionary to store filtered domain centroids (output).
461
- filtered_domain_terms (dict): Dictionary to store filtered domain terms (output).
462
- valid_indices (list): List to store valid indices (output).
460
+ filtered_domain_centroids (Dict[str, np.ndarray]): Dictionary to store filtered domain centroids (output).
461
+ filtered_domain_terms (Dict[str, str]): Dictionary to store filtered domain terms (output).
462
+ valid_indices (List): List to store valid indices (output).
463
463
 
464
464
  Note:
465
465
  The `filtered_domain_centroids`, `filtered_domain_terms`, and `valid_indices` are modified in-place.
@@ -551,9 +551,9 @@ class Labels:
551
551
  Args:
552
552
  domain (str): Domain ID to process.
553
553
  domain_centroid (np.ndarray): Centroid position of the domain.
554
- domain_id_to_centroid_map (dict): Mapping of domain IDs to their centroids.
555
- ids_to_replace (Union[Dict[str, str], None]): A dictionary mapping domain IDs to custom labels.
556
- words_to_omit (Union[List[str], None]): List of words to omit from the labels.
554
+ domain_id_to_centroid_map (Dict[str, np.ndarray]): Mapping of domain IDs to their centroids.
555
+ ids_to_replace (Dict[str, str], None, optional): A dictionary mapping domain IDs to custom labels. Defaults to None.
556
+ words_to_omit (List[str], None, optional): List of words to omit from the labels. Defaults to None.
557
557
  min_label_lines (int): Minimum number of lines required in a label.
558
558
  max_label_lines (int): Maximum number of lines allowed in a label.
559
559
  min_chars_per_line (int): Minimum number of characters allowed per line.
@@ -606,8 +606,8 @@ class Labels:
606
606
 
607
607
  Args:
608
608
  domain (str): The domain being processed.
609
- ids_to_replace (dict, optional): Dictionary mapping domain IDs to custom labels.
610
- words_to_omit (list, optional): List of words to omit from the labels.
609
+ ids_to_replace (Dict[str, str], optional): Dictionary mapping domain IDs to custom labels.
610
+ words_to_omit (List, optional): List of words to omit from the labels.
611
611
  max_label_lines (int): Maximum number of lines in a label.
612
612
  min_chars_per_line (int): Minimum number of characters in a line to display.
613
613
  max_chars_per_line (int): Maximum number of characters in a line to display.
@@ -637,7 +637,9 @@ class Labels:
637
637
  def get_annotated_label_colors(
638
638
  self,
639
639
  cmap: str = "gist_rainbow",
640
- color: Union[str, list, tuple, np.ndarray, None] = None,
640
+ color: Union[str, List, Tuple, np.ndarray, None] = None,
641
+ blend_colors: bool = False,
642
+ blend_gamma: float = 2.2,
641
643
  min_scale: float = 0.8,
642
644
  max_scale: float = 1.0,
643
645
  scale_factor: float = 1.0,
@@ -647,8 +649,10 @@ class Labels:
647
649
 
648
650
  Args:
649
651
  cmap (str, optional): Name of the colormap to use for generating label colors. Defaults to "gist_rainbow".
650
- color (str, list, tuple, np.ndarray, or None, optional): Color to use for the labels. Can be a single color or an array
652
+ color (str, List, Tuple, np.ndarray, or None, optional): Color to use for the labels. Can be a single color or an array
651
653
  of colors. If None, the colormap will be used. Defaults to None.
654
+ blend_colors (bool, optional): Whether to blend colors for nodes with multiple domains. Defaults to False.
655
+ blend_gamma (float, optional): Gamma correction factor for perceptual color blending. Defaults to 2.2.
652
656
  min_scale (float, optional): Minimum intensity scale for the colors generated by the colormap.
653
657
  Controls the dimmest colors. Defaults to 0.8.
654
658
  max_scale (float, optional): Maximum intensity scale for the colors generated by the colormap.
@@ -664,6 +668,8 @@ class Labels:
664
668
  graph=self.graph,
665
669
  cmap=cmap,
666
670
  color=color,
671
+ blend_colors=blend_colors,
672
+ blend_gamma=blend_gamma,
667
673
  min_scale=min_scale,
668
674
  max_scale=max_scale,
669
675
  scale_factor=scale_factor,
@@ -734,13 +740,13 @@ def _calculate_best_label_positions(
734
740
  """Calculate and optimize label positions for clarity.
735
741
 
736
742
  Args:
737
- filtered_domain_centroids (dict): Centroids of the filtered domains.
743
+ filtered_domain_centroids (Dict[str, Any]): Centroids of the filtered domains.
738
744
  center (np.ndarray): The center coordinates for label positioning.
739
745
  radius (float): The radius for positioning labels around the center.
740
746
  offset (float): The offset distance from the radius for positioning labels.
741
747
 
742
748
  Returns:
743
- dict: Optimized positions for labels.
749
+ Dict[str, Any]: Optimized positions for labels.
744
750
  """
745
751
  num_domains = len(filtered_domain_centroids)
746
752
  # Calculate equidistant positions around the center for initial label placement
@@ -768,7 +774,7 @@ def _calculate_equidistant_positions_around_center(
768
774
  num_domains (int): The number of positions (or domains) to calculate.
769
775
 
770
776
  Returns:
771
- list[np.ndarray]: List of positions (as 2D numpy arrays) around the center.
777
+ List[np.ndarray]: List of positions (as 2D numpy arrays) around the center.
772
778
  """
773
779
  # Calculate equidistant angles in radians around the center
774
780
  angles = np.linspace(0, 2 * np.pi, num_domains, endpoint=False)
@@ -785,11 +791,11 @@ def _optimize_label_positions(
785
791
  """Optimize label positions around the perimeter to minimize total distance to centroids.
786
792
 
787
793
  Args:
788
- best_label_positions (dict): Initial positions of labels around the perimeter.
789
- domain_centroids (dict): Centroid positions of the domains.
794
+ best_label_positions (Dict[str, Any]): Initial positions of labels around the perimeter.
795
+ domain_centroids (Dict[str, Any]): Centroid positions of the domains.
790
796
 
791
797
  Returns:
792
- dict: Optimized label positions.
798
+ Dict[str, Any]: Optimized label positions.
793
799
  """
794
800
  while True:
795
801
  improvement = False # Start each iteration assuming no improvement
@@ -821,8 +827,8 @@ def _calculate_total_distance(
821
827
  """Calculate the total distance from label positions to their domain centroids.
822
828
 
823
829
  Args:
824
- label_positions (dict): Positions of labels around the perimeter.
825
- domain_centroids (dict): Centroid positions of the domains.
830
+ label_positions (Dict[str, Any]): Positions of labels around the perimeter.
831
+ domain_centroids (Dict[str, Any]): Centroid positions of the domains.
826
832
 
827
833
  Returns:
828
834
  float: The total distance from labels to centroids.
@@ -845,10 +851,10 @@ def _swap_and_evaluate(
845
851
  """Swap two labels and evaluate the total distance after the swap.
846
852
 
847
853
  Args:
848
- label_positions (dict): Positions of labels around the perimeter.
854
+ label_positions (Dict[str, Any]): Positions of labels around the perimeter.
849
855
  i (int): Index of the first label to swap.
850
856
  j (int): Index of the second label to swap.
851
- domain_centroids (dict): Centroid positions of the domains.
857
+ domain_centroids (Dict[str, Any]): Centroid positions of the domains.
852
858
 
853
859
  Returns:
854
860
  float: The total distance after swapping the two labels.
@@ -45,11 +45,11 @@ class Network:
45
45
  node_shape (str, optional): Shape of the nodes. Defaults to "o".
46
46
  node_edgewidth (float, optional): Width of the node edges. Defaults to 1.0.
47
47
  edge_width (float, optional): Width of the edges. Defaults to 1.0.
48
- node_color (str, list, tuple, or np.ndarray, optional): Color of the nodes. Can be a single color or an array of colors.
48
+ node_color (str, List, Tuple, or np.ndarray, optional): Color of the nodes. Can be a single color or an array of colors.
49
49
  Defaults to "white".
50
- node_edgecolor (str, list, tuple, or np.ndarray, optional): Color of the node edges. Can be a single color or an array of colors.
50
+ node_edgecolor (str, List, Tuple, or np.ndarray, optional): Color of the node edges. Can be a single color or an array of colors.
51
51
  Defaults to "black".
52
- edge_color (str, list, tuple, or np.ndarray, optional): Color of the edges. Can be a single color or an array of colors.
52
+ edge_color (str, List, Tuple, or np.ndarray, optional): Color of the edges. Can be a single color or an array of colors.
53
53
  Defaults to "black".
54
54
  node_alpha (float, None, optional): Alpha value (transparency) for the nodes. If provided, it overrides any existing alpha
55
55
  values found in node_color. Defaults to 1.0. Annotated node_color alphas will override this value.
@@ -124,14 +124,14 @@ class Network:
124
124
  """Plot a subnetwork of selected nodes with customizable node and edge attributes.
125
125
 
126
126
  Args:
127
- nodes (list, tuple, or np.ndarray): List of node labels to include in the subnetwork. Accepts nested lists.
127
+ nodes (List, Tuple, or np.ndarray): List of node labels to include in the subnetwork. Accepts nested lists.
128
128
  node_size (int or np.ndarray, optional): Size of the nodes. Can be a single integer or an array of sizes. Defaults to 50.
129
129
  node_shape (str, optional): Shape of the nodes. Defaults to "o".
130
130
  node_edgewidth (float, optional): Width of the node edges. Defaults to 1.0.
131
131
  edge_width (float, optional): Width of the edges. Defaults to 1.0.
132
- node_color (str, list, tuple, or np.ndarray, optional): Color of the nodes. Defaults to "white".
133
- node_edgecolor (str, list, tuple, or np.ndarray, optional): Color of the node edges. Defaults to "black".
134
- edge_color (str, list, tuple, or np.ndarray, optional): Color of the edges. Defaults to "black".
132
+ node_color (str, List, Tuple, or np.ndarray, optional): Color of the nodes. Defaults to "white".
133
+ node_edgecolor (str, List, Tuple, or np.ndarray, optional): Color of the node edges. Defaults to "black".
134
+ edge_color (str, List, Tuple, or np.ndarray, optional): Color of the edges. Defaults to "black".
135
135
  node_alpha (float, None, optional): Transparency for the nodes. If provided, it overrides any existing alpha values
136
136
  found in node_color. Defaults to 1.0.
137
137
  edge_alpha (float, None, optional): Transparency for the edges. If provided, it overrides any existing alpha values
@@ -141,7 +141,7 @@ class Network:
141
141
  ValueError: If no valid nodes are found in the network graph.
142
142
  """
143
143
  # Flatten nested lists of nodes, if necessary
144
- if any(isinstance(item, (list, tuple, np.ndarray)) for item in nodes):
144
+ if any(isinstance(item, (List, Tuple, np.ndarray)) for item in nodes):
145
145
  nodes = [node for sublist in nodes for node in sublist]
146
146
 
147
147
  # Filter to get node IDs and their coordinates
@@ -154,7 +154,7 @@ class Network:
154
154
  raise ValueError("No nodes found in the network graph.")
155
155
 
156
156
  # Check if node_color is a single color or a list of colors
157
- if not isinstance(node_color, (str, tuple, np.ndarray)):
157
+ if not isinstance(node_color, (str, Tuple, np.ndarray)):
158
158
  node_color = [
159
159
  node_color[nodes.index(node)]
160
160
  for node in nodes
@@ -196,12 +196,14 @@ class Network:
196
196
  def get_annotated_node_colors(
197
197
  self,
198
198
  cmap: str = "gist_rainbow",
199
- color: Union[str, list, tuple, np.ndarray, None] = None,
199
+ color: Union[str, List, Tuple, np.ndarray, None] = None,
200
+ blend_colors: bool = False,
201
+ blend_gamma: float = 2.2,
200
202
  min_scale: float = 0.8,
201
203
  max_scale: float = 1.0,
202
204
  scale_factor: float = 1.0,
203
205
  alpha: Union[float, None] = 1.0,
204
- nonenriched_color: Union[str, list, tuple, np.ndarray] = "white",
206
+ nonenriched_color: Union[str, List, Tuple, np.ndarray] = "white",
205
207
  nonenriched_alpha: Union[float, None] = 1.0,
206
208
  random_seed: int = 888,
207
209
  ) -> np.ndarray:
@@ -209,14 +211,16 @@ class Network:
209
211
 
210
212
  Args:
211
213
  cmap (str, optional): Colormap to use for coloring the nodes. Defaults to "gist_rainbow".
212
- color (str, list, tuple, np.ndarray, or None, optional): Color to use for the nodes. Can be a single color or an array of colors.
214
+ color (str, List, Tuple, np.ndarray, or None, optional): Color to use for the nodes. Can be a single color or an array of colors.
213
215
  If None, the colormap will be used. Defaults to None.
216
+ blend_colors (bool, optional): Whether to blend colors for nodes with multiple domains. Defaults to False.
217
+ blend_gamma (float, optional): Gamma correction factor for perceptual color blending. Defaults to 2.2.
214
218
  min_scale (float, optional): Minimum scale for color intensity. Defaults to 0.8.
215
219
  max_scale (float, optional): Maximum scale for color intensity. Defaults to 1.0.
216
220
  scale_factor (float, optional): Factor for adjusting the color scaling intensity. Defaults to 1.0.
217
221
  alpha (float, None, optional): Alpha value for enriched nodes. If provided, it overrides any existing alpha values found in `color`.
218
222
  Defaults to 1.0.
219
- nonenriched_color (str, list, tuple, or np.ndarray, optional): Color for non-enriched nodes. Can be a single color or an array of colors.
223
+ nonenriched_color (str, List, Tuple, or np.ndarray, optional): Color for non-enriched nodes. Can be a single color or an array of colors.
220
224
  Defaults to "white".
221
225
  nonenriched_alpha (float, None, optional): Alpha value for non-enriched nodes. If provided, it overrides any existing alpha values found
222
226
  in `nonenriched_color`. Defaults to 1.0.
@@ -230,6 +234,8 @@ class Network:
230
234
  graph=self.graph,
231
235
  cmap=cmap,
232
236
  color=color,
237
+ blend_colors=blend_colors,
238
+ blend_gamma=blend_gamma,
233
239
  min_scale=min_scale,
234
240
  max_scale=max_scale,
235
241
  scale_factor=scale_factor,
@@ -38,8 +38,8 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
38
38
 
39
39
  Args:
40
40
  graph (NetworkGraph): The network data and attributes to be visualized.
41
- figsize (tuple, optional): Size of the figure in inches (width, height). Defaults to (10, 10).
42
- background_color (str, list, tuple, np.ndarray, optional): Background color of the plot. Defaults to "white".
41
+ figsize (Tuple, optional): Size of the figure in inches (width, height). Defaults to (10, 10).
42
+ background_color (str, List, Tuple, np.ndarray, optional): Background color of the plot. Defaults to "white".
43
43
  background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides
44
44
  any existing alpha values found in background_color. Defaults to 1.0.
45
45
  pad (float, optional): Padding value to adjust the axis limits. Defaults to 0.3.
@@ -59,7 +59,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
59
59
  self,
60
60
  graph: NetworkGraph,
61
61
  figsize: Tuple,
62
- background_color: Union[str, list, tuple, np.ndarray],
62
+ background_color: Union[str, List, Tuple, np.ndarray],
63
63
  background_alpha: Union[float, None],
64
64
  pad: float,
65
65
  ) -> plt.Axes:
@@ -67,8 +67,8 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
67
67
 
68
68
  Args:
69
69
  graph (NetworkGraph): The network data and attributes to be visualized.
70
- figsize (tuple): Size of the figure in inches (width, height).
71
- background_color (str, list, tuple, or np.ndarray): Background color of the plot. Can be a single color or an array of colors.
70
+ figsize (Tuple): Size of the figure in inches (width, height).
71
+ background_color (str, List, Tuple, or np.ndarray): Background color of the plot. Can be a single color or an array of colors.
72
72
  background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides any existing
73
73
  alpha values found in `background_color`.
74
74
  pad (float, optional): Padding value to adjust the axis limits.