Skip to content

Commit

Permalink
[skip ci] Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 3, 2020
1 parent 7eaea00 commit 7b88bdd
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 36 deletions.
5 changes: 4 additions & 1 deletion examples/features/images_cats_and_dogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# However, popular larger files shouldn't be a problem (LFW, CelebA).
data_path = get_data_path() / "cat-and-dog"
kaggle.api.dataset_download_files(
"tongpython/cat-and-dog", path=str(data_path), quiet=False, unzip=True,
"tongpython/cat-and-dog",
path=str(data_path),
quiet=False,
unzip=True,
)

# At the first run, we find that the dataset not only contains images, "_DS_Store" and "cat-and-dog.zip" are present too.
Expand Down
18 changes: 15 additions & 3 deletions src/pandas_profiling/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,28 @@ def set_file(self, file_name: Union[str, Path]) -> None:
"vars": {"cat": {"redact": True}},
},
"dark_mode": {
"html": {"style": {"theme": "flatly", "primary_color": "#2c3e50",}}
"html": {
"style": {
"theme": "flatly",
"primary_color": "#2c3e50",
}
}
},
"orange_mode": {
"html": {"style": {"theme": "united", "primary_color": "#d34615",}}
"html": {
"style": {
"theme": "united",
"primary_color": "#d34615",
}
}
},
"explorative": {
"vars": {
"cat": {"unicode": True},
"file": {"active": True},
"image": {"active": True,},
"image": {
"active": True,
},
},
"n_obs_unique": 10,
"n_extreme_obs": 10,
Expand Down
2 changes: 1 addition & 1 deletion src/pandas_profiling/controller/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def parse_args(args: Union[list, None] = None) -> argparse.Namespace:


def main(args=None) -> None:
""" Run the `pandas_profiling` package.
"""Run the `pandas_profiling` package.
Args:
args: Arguments for the programme (Default value=None).
Expand Down
16 changes: 8 additions & 8 deletions src/pandas_profiling/model/correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ def calculate_correlation(
df: pd.DataFrame, variables: dict, correlation_name: str
) -> Union[pd.DataFrame, None]:
"""Calculate the correlation coefficients between variables for the correlation types selected in the config
(pearson, spearman, kendall, phi_k, cramers).
(pearson, spearman, kendall, phi_k, cramers).
Args:
variables: A dict with column names and variable types.
df: The DataFrame with variables.
correlation_name:
Args:
variables: A dict with column names and variable types.
df: The DataFrame with variables.
correlation_name:
Returns:
The correlation matrices for the given correlation measures. Return None if correlation is empty.
"""
Returns:
The correlation matrices for the given correlation measures. Return None if correlation is empty.
"""

categorical_correlations = {"cramers": cramers_matrix}
correlation = None
Expand Down
8 changes: 7 additions & 1 deletion src/pandas_profiling/model/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ def describe(title: str, df: pd.DataFrame, sample: Optional[dict] = None) -> dic

correlation_names = [
correlation_name
for correlation_name in ["pearson", "spearman", "kendall", "phi_k", "cramers",]
for correlation_name in [
"pearson",
"spearman",
"kendall",
"phi_k",
"cramers",
]
if config["correlations"][correlation_name]["calculate"].get(bool)
]

Expand Down
6 changes: 3 additions & 3 deletions src/pandas_profiling/model/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def describe_numeric_1d(series: pd.Series, series_description: dict) -> dict:
"""

def mad(arr):
""" Median Absolute Deviation: a "Robust" version of standard deviation.
Indices variability of the sample.
https://en.wikipedia.org/wiki/Median_absolute_deviation
"""Median Absolute Deviation: a "Robust" version of standard deviation.
Indices variability of the sample.
https://en.wikipedia.org/wiki/Median_absolute_deviation
"""
return np.median(np.abs(arr - np.median(arr)))

Expand Down
10 changes: 8 additions & 2 deletions src/pandas_profiling/report/structure/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def get_duplicates_items(duplicates: pd.DataFrame):
if duplicates is not None and len(duplicates) > 0:
items.append(
Duplicate(
duplicate=duplicates, name="Most frequent", anchor_id="duplicates",
duplicate=duplicates,
name="Most frequent",
anchor_id="duplicates",
)
)
return items
Expand All @@ -192,7 +194,11 @@ def get_definition_items(definitions: pd.DataFrame):
items = []
if definitions is not None and len(definitions) > 0:
items.append(
Duplicate(duplicate=definitions, name="Columns", anchor_id="definitions",)
Duplicate(
duplicate=definitions,
name="Columns",
anchor_id="definitions",
)
)
return items

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ def render_categorical_unicode(summary, varid, redact):
]

return Container(
citems, name="Unicode", sequence_type="tabs", anchor_id=f"{varid}unicode",
citems,
name="Unicode",
sequence_type="tabs",
anchor_id=f"{varid}unicode",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def render_file(summary):
)

file_tab = Container(
file_tabs, name="File", sequence_type="tabs", anchor_id=f"{varid}file",
file_tabs,
name="File",
sequence_type="tabs",
anchor_id=f"{varid}file",
)

template_variables["bottom"].content["items"].append(file_tab)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def render_image(summary):
image_items.append(image_shape)

image_tab = Container(
image_items, name="Image", sequence_type="tabs", anchor_id=f"{varid}image",
image_items,
name="Image",
sequence_type="tabs",
anchor_id=f"{varid}image",
)

template_variables["bottom"].content["items"].append(image_tab)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def render_path(summary):
]

path_tab = Container(
path_items, name="Path", sequence_type="tabs", anchor_id=f"{varid}path",
path_items,
name="Path",
sequence_type="tabs",
anchor_id=f"{varid}path",
)

template_variables["bottom"].content["items"].append(path_tab)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ def render_real(summary):
)

template_variables["bottom"] = Container(
[statistics, hist, fq, evs], sequence_type="tabs", anchor_id=f"{varid}bottom",
[statistics, hist, fq, evs],
sequence_type="tabs",
anchor_id=f"{varid}bottom",
)

return template_variables
8 changes: 4 additions & 4 deletions src/pandas_profiling/serialize_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def dump(self, output_file: Union[Path, str]):

def load(self, load_file: Union[Path, str], ignore_config: bool = False):
"""
Load ProfileReport from file
Load ProfileReport from file
Raises:
ValueError: if the DataFrame or Config do not match with the current ProfileReport
"""
Raises:
ValueError: if the DataFrame or Config do not match with the current ProfileReport
"""
if not isinstance(load_file, Path):
load_file = Path(str(load_file))

Expand Down
2 changes: 1 addition & 1 deletion src/pandas_profiling/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def update(d: dict, u: Mapping) -> dict:
""" Recursively update a dict.
"""Recursively update a dict.
Args:
d: Dictionary to update.
Expand Down
3 changes: 1 addition & 2 deletions src/pandas_profiling/visualisation/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

@contextlib.contextmanager
def manage_matplotlib_context():
"""Return a context manager for temporarily changing matplotlib unit registries and rcParams.
"""
"""Return a context manager for temporarily changing matplotlib unit registries and rcParams."""
originalRcParams = matplotlib.rcParams.copy()

## Credits for this style go to the ggplot and seaborn packages.
Expand Down
4 changes: 3 additions & 1 deletion src/pandas_profiling/visualisation/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ def correlation_matrix(data: pd.DataFrame, vmin: int = -1) -> str:
legend_elements = [Patch(facecolor=cmap(np.nan), label="invalid\ncoefficient")]

plt.legend(
handles=legend_elements, loc="upper right", handleheight=2.5,
handles=legend_elements,
loc="upper right",
handleheight=2.5,
)

axes_cor.set_xticks(np.arange(0, data.shape[0], float(data.shape[0]) / len(labels)))
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/test_dataset_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def test_dataset_schema():
)

# Length left out due to correlation with weight.
report = df.profile_report(title="Dataset schema", dataset=metadata, minimal=True,)
report = df.profile_report(
title="Dataset schema",
dataset=metadata,
minimal=True,
)

html = report.to_html()

Expand All @@ -36,7 +40,9 @@ def test_dataset_schema_empty():

# Length left out due to correlation with weight.
report = df.profile_report(
title="Dataset schema empty", minimal=True, dataset=None,
title="Dataset schema empty",
minimal=True,
dataset=None,
)

html = report.to_html()
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_html_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def test_html_export_cdn(test_output_dir):
)

profile = df.profile_report(
minimal=True, html={"inline": False, "use_local_assets": False},
minimal=True,
html={"inline": False, "use_local_assets": False},
)

report = test_output_dir / "cdn.html"
Expand All @@ -96,7 +97,8 @@ def test_html_export_theme(test_output_dir):
)

profile = df.profile_report(
minimal=True, html={"inline": False, "style": {"theme": "united"}},
minimal=True,
html={"inline": False, "style": {"theme": "united"}},
)

report = test_output_dir / "united.html"
Expand Down

0 comments on commit 7b88bdd

Please sign in to comment.