d3graph 2.9.1__tar.gz → 2.9.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d3graph
3
- Version: 2.9.1
3
+ Version: 2.9.2
4
4
  Summary: Python package to create interactive network based on d3js.
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -17,7 +17,7 @@ from d3graph.d3graph import (
17
17
 
18
18
  __author__ = 'Erdogan Tasksen'
19
19
  __email__ = 'erdogant@gmail.com'
20
- __version__ = '2.9.1'
20
+ __version__ = '2.9.2'
21
21
 
22
22
  # Setup root logger
23
23
  _logger = logging.getLogger('d3graph')
@@ -253,6 +253,7 @@ class d3graph:
253
253
  edge_style=0,
254
254
  edge_color: (str, list) = '#808080',
255
255
  edge_opacity: (float, str, list) = 'weight',
256
+ min_weight: float = 1.0,
256
257
  scaler: str = 'zscore',
257
258
  directed: bool = False,
258
259
  marker_start=None,
@@ -287,6 +288,8 @@ class d3graph:
287
288
  edge_opacity : (float, str, list), (default: 1.0)
288
289
  * 0.8 : Opacity of the edges [0-1] where 0=transparent and 1=fully opaque.
289
290
  * 'weight' : Set opacity based on the weight of the edge and the scaler
291
+ min_weight : float
292
+ edges are kept with >= weight.
290
293
  scaler : str, (default: 'zscore')
291
294
  Scale the edge-width using the following scaler:
292
295
  * 'zscore' : Scale values to Z-scores.
@@ -346,6 +349,7 @@ class d3graph:
346
349
  self.config['label'] = label
347
350
  self.config['label_color'] = label_color
348
351
  self.config['label_fontsize'] = label_fontsize
352
+ self.config['min_weight'] = min_weight
349
353
 
350
354
  if not hasattr(self, 'adjmat'):
351
355
  logger.error('adjmat is missing. Initialize first with d3 = d3graph(adjmat)')
@@ -367,7 +371,7 @@ class d3graph:
367
371
  logger.info('Set the edge properties')
368
372
  self.edge_properties, self.adjmat = adjmat2dict(
369
373
  self.adjmat,
370
- filter_weight=0,
374
+ min_weight=self.config['min_weight'],
371
375
  minmax=self.config['minmax'],
372
376
  minmax_distance=self.config['minmax_distance'],
373
377
  scaler=self.config['edge_scaler'],
@@ -698,6 +702,7 @@ class d3graph:
698
702
 
699
703
  def graph(self,
700
704
  adjmat,
705
+ min_weight: float = 1.0,
701
706
  color: str = 'cluster',
702
707
  opacity: str = 'degree',
703
708
  size='degree',
@@ -712,6 +717,8 @@ class d3graph:
712
717
  ----------
713
718
  adjmat : pd.DataFrame()
714
719
  Adjacency matrix (symmetric and Values > 0 are edges).
720
+ min_weight : float
721
+ edges are kept with >= weight.
715
722
  color : list of strings (default: 'cluster')
716
723
  Coloring of the nodes.
717
724
  * 'cluster' or None : Colours are based on the community distance clusters.
@@ -765,7 +772,7 @@ class d3graph:
765
772
  # Checks
766
773
  self.adjmat = data_checks(adjmat.copy())
767
774
  # Set default edge properties
768
- self.set_edge_properties(scaler=scaler)
775
+ self.set_edge_properties(scaler=scaler, min_weight=min_weight)
769
776
  # Set default node properties
770
777
  self.set_node_properties(color=color, opacity=opacity, size=size, scaler=scaler, cmap=cmap)
771
778
 
@@ -1060,7 +1067,7 @@ def json_create(G: nx.Graph) -> str:
1060
1067
 
1061
1068
  # %% Convert adjacency matrix to vector
1062
1069
  def adjmat2dict(adjmat: pd.DataFrame,
1063
- filter_weight: float = 0.0,
1070
+ min_weight: float = 1.0,
1064
1071
  scaler: str = 'zscore',
1065
1072
  marker_start=None,
1066
1073
  marker_end='arrow',
@@ -1084,8 +1091,8 @@ def adjmat2dict(adjmat: pd.DataFrame,
1084
1091
  ----------
1085
1092
  adjmat : pd.DataFrame()
1086
1093
  Adjacency matrix.
1087
- filter_weight : float
1088
- edges are returned with a minimum weight.
1094
+ min_weight : float
1095
+ edges are kept with >= weight.
1089
1096
  scaler : str, (default: 'zscore')
1090
1097
  Scale the edge-width using the following scaler:
1091
1098
  'zscore' : Scale values to Z-scores.
@@ -1163,14 +1170,14 @@ def adjmat2dict(adjmat: pd.DataFrame,
1163
1170
  # # Remove self loops and no-connected edges
1164
1171
  # Iloc = df['source'] != df['target']
1165
1172
  # # Keep only edges with a minimum edge strength
1166
- # if filter_weight is not None:
1167
- # logger.info(f"Keep only edges with weight>{filter_weight}")
1168
- # Iloc2 = df['weight'] > filter_weight
1173
+ # if min_weight is not None:
1174
+ # logger.info(f"Keep only edges with weight>{min_weight}")
1175
+ # Iloc2 = df['weight'] > min_weight
1169
1176
  # Iloc = Iloc & Iloc2
1170
1177
  # df = df.loc[Iloc, :]
1171
1178
  # df.reset_index(drop=True, inplace=True)
1172
1179
 
1173
- df = adjmat2vec(adjmat)
1180
+ df = adjmat2vec(adjmat, min_weight=min_weight)
1174
1181
 
1175
1182
  # Scale the weights for visualization purposes
1176
1183
  if minmax_distance is not None:
@@ -6,7 +6,7 @@ import time
6
6
 
7
7
  df = pd.read_csv('https://github.com/d3blocks/d3blocks/files/11995798/Df.csv', sep=',', index_col=False)
8
8
  del df['Unnamed: 0']
9
- df = df[0:10000]
9
+ df = df[0:5000]
10
10
  adjmat = vec2adjmat(source=df['source'], target=df['target'], weight=df['weight'])
11
11
 
12
12
  d3 = d3graph()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d3graph
3
- Version: 2.9.1
3
+ Version: 2.9.2
4
4
  Summary: Python package to create interactive network based on d3js.
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License-Expression: BSD-3-Clause
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes