Skip to content

Commit

Permalink
fix: fix linter errors (#1117)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquemy authored and portellaa committed Oct 20, 2022
1 parent 21f4fe6 commit 5f17cfd
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 42 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
run: make lint

- name: Commit code formatting changes
if: always()
id: commit
run: |
if [[ `git status --porcelain --untracked-files=no` ]]; then
Expand Down
4 changes: 1 addition & 3 deletions src/pandas_profiling/model/correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def compute(config: Settings, df: Sized, summary: dict) -> Optional[Sized]:
class Auto(Correlation):
@staticmethod
@multimethod
def compute(
config: Settings, df: Sized, summary: dict
) -> Optional[Sized]:
def compute(config: Settings, df: Sized, summary: dict) -> Optional[Sized]:
raise NotImplementedError()


Expand Down
4 changes: 1 addition & 3 deletions src/pandas_profiling/model/pandas/correlations_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def pandas_phik_compute(

@Auto.compute.register(Settings, pd.DataFrame, dict)
def pandas_auto_compute(
config: Settings,
df: pd.DataFrame,
summary: dict
config: Settings, df: pd.DataFrame, summary: dict
) -> Optional[pd.DataFrame]:
threshold = config.categorical_maximum_correlation_distinct

Expand Down
21 changes: 15 additions & 6 deletions src/pandas_profiling/model/pandas/describe_categorical_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ def counter_to_series(counter: Counter) -> pd.Series:

def unicode_summary_vc(vc: pd.Series) -> dict:
try:
from tangled_up_in_unicode import block, block_abbr, category, category_long, script
from tangled_up_in_unicode import ( # type: ignore
block,
block_abbr,
category,
category_long,
script,
)
except ImportError:
from unicodedata import category
block = lambda char: "(unknown)"
block_abbr = lambda char: "(unknown)"
category_long = lambda char: "(unknown)"
script = lambda char: "(unknown)"
from unicodedata import category as _category # pylint: disable=import-error

category = _category # type: ignore
char_handler = lambda char: "(unknown)" # noqa: E731
block = char_handler
block_abbr = char_handler
category_long = char_handler
script = char_handler

# Unicode Character Summaries (category and script name)
character_counts = get_character_counts_vc(vc)
Expand Down
19 changes: 16 additions & 3 deletions src/pandas_profiling/report/presentation/core/dropdown.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
from typing import Any, Callable

from pandas_profiling.report.presentation.core.item_renderer import ItemRenderer
from pandas_profiling.report.presentation.core.container import Container
from pandas_profiling.report.presentation.core.item_renderer import ItemRenderer
from pandas_profiling.report.presentation.core.renderable import Renderable


class Dropdown(ItemRenderer):
def __init__(self, name: str, id: str, items: list, item: Container, anchor_id: str, **kwargs):
super().__init__("dropdown", {"name": name, "id": id, "items": items, "item": item, "anchor_id": anchor_id,}, **kwargs)
def __init__(
self, name: str, id: str, items: list, item: Container, anchor_id: str, **kwargs
):
super().__init__(
"dropdown",
{
"name": name,
"id": id,
"items": items,
"item": item,
"anchor_id": anchor_id,
},
**kwargs
)

def __repr__(self) -> str:
return "Dropdown"
Expand Down
4 changes: 2 additions & 2 deletions src/pandas_profiling/report/presentation/flavours/flavours.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def get_widget_renderable_mapping() -> Dict[Type[Renderable], Type[Renderable]]:
Alerts,
Collapse,
Container,
Duplicate,
Dropdown,
Duplicate,
FrequencyTable,
FrequencyTableSmall,
Image,
Expand All @@ -108,8 +108,8 @@ def get_widget_renderable_mapping() -> Dict[Type[Renderable], Type[Renderable]]:
WidgetAlerts,
WidgetCollapse,
WidgetContainer,
WidgetDuplicate,
WidgetDropdown,
WidgetDuplicate,
WidgetFrequencyTable,
WidgetFrequencyTableSmall,
WidgetHTML,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
from pandas_profiling.report.presentation.flavours.widget.container import (
WidgetContainer,
)
from pandas_profiling.report.presentation.flavours.widget.dropdown import WidgetDropdown
from pandas_profiling.report.presentation.flavours.widget.duplicate import (
WidgetDuplicate,
)
from pandas_profiling.report.presentation.flavours.widget.dropdown import (
WidgetDropdown,
)
from pandas_profiling.report.presentation.flavours.widget.frequency_table import (
WidgetFrequencyTable,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
class WidgetDropdown(Dropdown):
def render(self) -> widgets.VBox:
dropdown = widgets.Dropdown(
options=self.content["items"],
description=self.content["name"]
options=self.content["items"], description=self.content["name"]
)
titles = []
item = self.content["item"].content["items"]
for i in item:
for i in item:
titles.append(i.name)
item = self.content["item"].render()

def change_view(widg: dict) -> None:
if(dropdown.value == ""):
if dropdown.value == "":
item.selected_index = None
else:
for i in range(len(titles)):
if(titles[i] == dropdown.value):
if titles[i] == dropdown.value:
item.selected_index = i
break

dropdown.observe(change_view, names=["value"])
dropdown.observe(change_view, names=["value"])

if(self.content["item"] != None):
if self.content["item"] is not None:
return widgets.VBox([dropdown, item])
else:
return widgets.Vbox([dropdown])
19 changes: 4 additions & 15 deletions src/pandas_profiling/report/structure/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ def render_variables_section(config: Settings, dataframe_summary: dict) -> list:
"""

templs = []
# dropdown = Dropdown(
# name="variables-dropdown",
# id="variables-dropdown",
# items=list(dataframe_summary["variables"]),
# )
# templs.append(dropdown)

descriptions = config.variables.descriptions
show_description = config.show_variable_description
Expand Down Expand Up @@ -105,8 +99,7 @@ def render_variables_section(config: Settings, dataframe_summary: dict) -> list:
template_variables.update(summary)

# Per type template variables
render_map_type = render_map.get(
summary["type"], render_map["Unsupported"])
render_map_type = render_map.get(summary["type"], render_map["Unsupported"])
template_variables.update(render_map_type(config, template_variables))

# Ignore these
Expand All @@ -117,8 +110,7 @@ def render_variables_section(config: Settings, dataframe_summary: dict) -> list:

bottom = None
if "bottom" in template_variables and template_variables["bottom"] is not None:
btn = ToggleButton(
"Toggle details", anchor_id=template_variables["varid"])
btn = ToggleButton("Toggle details", anchor_id=template_variables["varid"])
bottom = Collapse(btn, template_variables["bottom"])

var = Variable(
Expand Down Expand Up @@ -186,8 +178,7 @@ def get_sample_items(sample: dict) -> List[Sample]:
List of sample items to show in the interface.
"""
items = [
Sample(sample=obj.data, name=obj.name,
anchor_id=obj.id, caption=obj.caption)
Sample(sample=obj.data, name=obj.name, anchor_id=obj.id, caption=obj.caption)
for obj in sample
]
return items
Expand Down Expand Up @@ -275,14 +266,12 @@ def get_report_structure(config: Settings, summary: dict) -> Root:
section_items.append(
Container(
scatter_items,
sequence_type="tabs" if len(
scatter_items) <= 10 else "select",
sequence_type="tabs" if len(scatter_items) <= 10 else "select",
name="Interactions",
anchor_id="interactions",
),
)


corr = get_correlation_items(config, summary)
if corr is not None:
section_items.append(corr)
Expand Down

0 comments on commit 5f17cfd

Please sign in to comment.