d3graph 2.8.0__tar.gz → 2.8.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d3graph
3
- Version: 2.8.0
3
+ Version: 2.8.1
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.8.0'
20
+ __version__ = '2.8.1'
21
21
 
22
22
  # Setup root logger
23
23
  _logger = logging.getLogger('d3graph')
@@ -1602,20 +1602,52 @@ def adjmat2vec(adjmat, min_weight: float = 1.0) -> pd.DataFrame:
1602
1602
  return adjmat
1603
1603
 
1604
1604
 
1605
+ # def _check_hex_color(color, n=None, cmap='Set1'):
1606
+ # if isinstance(color, str) and len(color) != 7:
1607
+ # logger.warning('Input parameter [color] has wrong format. Must be like color="#000000" <auto-fixing>')
1608
+ # return get_hex_color(color, cmap=cmap)[0]
1609
+ # if isinstance(color, (list, np.ndarray, pd.Series, pd.Series, StringArray)) and len(color) == 0:
1610
+ # logger.warning('Input parameter [color] has wrong format and length. Must be like: color=["#000000", "...", "#000000"] <auto-fixing>')
1611
+ # return get_hex_color(color, cmap=cmap)[0]
1612
+ # if isinstance(color, (list, np.ndarray, pd.Series, pd.Series, StringArray)) and (not np.all(list(map(lambda x: len(x) == 7, color)))):
1613
+ # logger.warning('[color] contains incorrect hex-colors. Hex must be of length 7: ["#000000", "#000000", etc] <auto-fixing>')
1614
+ # return get_hex_color(color, cmap=cmap)[0]
1615
+ # if (n is not None) and isinstance(color, (list, np.ndarray, pd.Series, pd.Series, StringArray)) and len(color) != n:
1616
+ # logger.warning(f'Input parameter [color] has wrong length. Must be of length: {str(n)} <auto-fixing>')
1617
+ # return get_hex_color(color, cmap=cmap)[0]
1618
+ # # Return original input
1619
+ # return color
1620
+
1605
1621
  def _check_hex_color(color, n=None, cmap='Set1'):
1606
- if isinstance(color, str) and len(color) != 7:
1607
- logger.warning('Input parameter [color] has wrong format. Must be like color="#000000" <auto-fixing>')
1608
- return get_hex_color(color, cmap=cmap)[0]
1609
- if isinstance(color, (list, np.ndarray, pd.Series, pd.Series, StringArray)) and len(color) == 0:
1610
- logger.warning('Input parameter [color] has wrong format and length. Must be like: color=["#000000", "...", "#000000"] <auto-fixing>')
1611
- return get_hex_color(color, cmap=cmap)[0]
1612
- if isinstance(color, (list, np.ndarray, pd.Series, pd.Series, StringArray)) and (not np.all(list(map(lambda x: len(x) == 7, color)))):
1613
- logger.warning('[color] contains incorrect hex-colors. Hex must be of length 7: ["#000000", "#000000", etc] <auto-fixing>')
1614
- return get_hex_color(color, cmap=cmap)[0]
1615
- if (n is not None) and isinstance(color, (list, np.ndarray, pd.Series, pd.Series, StringArray)) and len(color) != n:
1616
- logger.warning(f'Input parameter [color] has wrong length. Must be of length: {str(n)} <auto-fixing>')
1617
- return get_hex_color(color, cmap=cmap)[0]
1618
- # Return original input
1622
+ seq_types = (list, np.ndarray, pd.Series, StringArray)
1623
+
1624
+ # Single string
1625
+ if isinstance(color, str):
1626
+ if len(color) != 7 or not color.startswith('#'):
1627
+ logger.warning('Invalid [color] format. Expected "#000000" <auto-fixing>')
1628
+ return get_hex_color(color, cmap=cmap)[0]
1629
+ return color
1630
+
1631
+ # Sequence input
1632
+ if isinstance(color, seq_types):
1633
+
1634
+ if len(color) == 0:
1635
+ logger.warning('Invalid [color] sequence. Expected ["#000000", ...] <auto-fixing>')
1636
+ return get_hex_color(color, cmap=cmap)[0]
1637
+
1638
+ valid = np.all([
1639
+ isinstance(x, str) and len(x) == 7 and x.startswith('#')
1640
+ for x in color
1641
+ ])
1642
+
1643
+ if not valid:
1644
+ logger.warning('Invalid hex colors in [color]. Expected ["#000000", ...] <auto-fixing>')
1645
+ return get_hex_color(color, cmap=cmap)[0]
1646
+
1647
+ if (n is not None) and (len(color) != n):
1648
+ logger.warning(f'Invalid [color] length. Expected length={n} <auto-fixing>')
1649
+ return get_hex_color(color, cmap=cmap)[0]
1650
+
1619
1651
  return color
1620
1652
 
1621
1653
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d3graph
3
- Version: 2.8.0
3
+ Version: 2.8.1
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
File without changes