MatplotLibAPI 3.1.1__tar.gz → 3.1.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.
@@ -6,8 +6,7 @@ import matplotlib.pyplot as plt
6
6
  from matplotlib.axes import Axes
7
7
  import seaborn as sns
8
8
 
9
- from . import DynamicFuncFormatter, StyleTemplate, generate_ticks, string_formatter, bmk_formatter, percent_formatter, format_func
10
- from .. import validate_dataframe
9
+ from . import DynamicFuncFormatter, StyleTemplate, generate_ticks, string_formatter, bmk_formatter, percent_formatter, format_func,validate_dataframe
11
10
 
12
11
  BUBBLE_STYLE_TEMPLATE = StyleTemplate(
13
12
  format_funcs={"label": string_formatter,
@@ -8,8 +8,7 @@ from matplotlib.figure import Figure
8
8
  from .Network import plot_network, plot_network_components, DEFAULT
9
9
  from .Bubble import plot_bubble, BUBBLE_STYLE_TEMPLATE
10
10
  from .Table import plot_table
11
- from . import StyleTemplate, format_func
12
- from .. import validate_dataframe
11
+ from . import StyleTemplate, format_func, validate_dataframe
13
12
 
14
13
 
15
14
  def plot_composite_bubble(
@@ -13,8 +13,7 @@ from networkx import Graph
13
13
  from networkx.classes.graph import Graph
14
14
 
15
15
 
16
- from . import StyleTemplate, string_formatter, format_func
17
- from .. import validate_dataframe
16
+ from . import StyleTemplate, string_formatter, format_func,validate_dataframe
18
17
 
19
18
  NETWORK_STYLE_TEMPLATE = StyleTemplate(
20
19
  )
@@ -3,8 +3,7 @@ import pandas as pd
3
3
  import matplotlib.pyplot as plt
4
4
  from matplotlib.axes import Axes
5
5
 
6
- from . import StyleTemplate, string_formatter
7
- from .. import validate_dataframe
6
+ from . import StyleTemplate, string_formatter,validate_dataframe
8
7
 
9
8
  TABLE_STYLE_TEMPLATE = StyleTemplate(
10
9
  background_color='black',
@@ -6,8 +6,7 @@ import matplotlib.pyplot as plt
6
6
  from matplotlib.axes import Axes
7
7
  import seaborn as sns
8
8
 
9
- from . import DynamicFuncFormatter, StyleTemplate, string_formatter, bmk_formatter, format_func
10
- from .. import validate_dataframe
9
+ from . import DynamicFuncFormatter, StyleTemplate, string_formatter, bmk_formatter, format_func,validate_dataframe
11
10
 
12
11
 
13
12
  TIMESERIE_STYLE_TEMPLATE = StyleTemplate(
@@ -2,10 +2,11 @@
2
2
  # %%
3
3
  from typing import Optional
4
4
  import pandas as pd
5
+ from pandas import CategoricalDtype,BooleanDtype
5
6
  import plotly.graph_objects as go
6
7
 
7
- from . import StyleTemplate, string_formatter, percent_formatter
8
- from .. import validate_dataframe
8
+ from . import StyleTemplate, string_formatter, percent_formatter,validate_dataframe
9
+
9
10
 
10
11
 
11
12
  TREEMAP_STYLE_TEMPLATE = StyleTemplate(
@@ -49,9 +50,9 @@ def plot_treemap(pd_df: pd.DataFrame,
49
50
 
50
51
  if color and color in pd_df.columns:
51
52
  color_data = pd_df[color]
52
- if pd.api.types.is_categorical_dtype(color_data) or pd.api.types.is_object_dtype(color_data):
53
+ if isinstance(color_data, CategoricalDtype) or pd.api.types.is_object_dtype(color_data):
53
54
  color_data = color_data.astype('category').cat.codes
54
- elif pd.api.types.is_bool_dtype(color_data):
55
+ elif isinstance(color_data, BooleanDtype):
55
56
  color_data = color_data.astype(int)
56
57
  data['marker'] = dict(colorscale="Viridis",
57
58
  colors=color_data.to_list())
@@ -1,4 +1,10 @@
1
1
 
2
+ from .Treemap import plot_treemap, TREEMAP_STYLE_TEMPLATE
3
+ from .Network import Graph
4
+ from .Table import plot_table, TABLE_STYLE_TEMPLATE
5
+ from .Timeserie import plot_timeserie, TIMESERIE_STYLE_TEMPLATE
6
+ from .Composite import plot_composite_bubble
7
+ from .Bubble import plot_bubble, BUBBLE_STYLE_TEMPLATE
2
8
  from typing import List, Optional, Dict, Callable, Union
3
9
  from dataclasses import dataclass
4
10
  import pandas as pd
@@ -11,16 +17,19 @@ from matplotlib.dates import num2date
11
17
  from matplotlib.ticker import FuncFormatter
12
18
  import plotly.graph_objects as go
13
19
 
14
- from . import StyleTemplate
15
- from .Bubble import plot_bubble, BUBBLE_STYLE_TEMPLATE
16
- from .Composite import plot_composite_bubble
17
- from .Timeserie import plot_timeserie, TIMESERIE_STYLE_TEMPLATE
18
- from .Table import plot_table, TABLE_STYLE_TEMPLATE
19
- from .Network import Graph
20
- from .Treemap import plot_treemap, TREEMAP_STYLE_TEMPLATE
21
20
 
22
21
  # region Utils
23
22
 
23
+ def validate_dataframe(pd_df: pd.DataFrame,
24
+ cols: List[str],
25
+ sort_by: Optional[str] = None):
26
+ _columns = cols.copy()
27
+ if sort_by and sort_by not in _columns:
28
+ _columns.append(sort_by)
29
+ for col in _columns:
30
+ if col not in pd_df.columns:
31
+ raise AttributeError(f"{col} is not a DataFrame's column")
32
+
24
33
 
25
34
  def format_func(
26
35
  format_funcs: Optional[Dict[str, Optional[Callable[[Union[int, float, str]], str]]]],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.1.1
3
+ Version: 3.1.2
4
4
  Requires-Python: >=3.7
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.1.1
3
+ Version: 3.1.2
4
4
  Requires-Python: >=3.7
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "MatplotLibAPI"
6
- version="v3.1.1"
6
+ version="v3.1.2"
7
7
  readme = "README.md"
8
8
  requires-python=">=3.7"
9
9
  dependencies = ["pandas","matplotlib","networkx","plotly","seaborn","scikit-learn","kaleido","nbformat"]
File without changes
File without changes
File without changes