Skip to content

Commit 886be38

Browse files
azory-ydatafabclmnt
authored andcommitted
fix(linting): code formatting
1 parent 3f126b0 commit 886be38

3 files changed

Lines changed: 34 additions & 23 deletions

File tree

src/ydata_profiling/profile_report.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ def __initialize_dataframe(
199199
) -> Optional[Union[pd.DataFrame, sDataFrame]]:
200200

201201
logger.info_def_report(
202-
df=df, timeseries=report_config.vars.timeseries.active,
202+
df=df,
203+
timeseries=report_config.vars.timeseries.active,
203204
)
204205

205206
if (

src/ydata_profiling/utils/common.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,9 @@ def convert_timestamp_to_datetime(timestamp: int) -> datetime:
9999
return datetime(1970, 1, 1) + timedelta(seconds=int(timestamp))
100100

101101

102-
def analytics_features(dataframe: str,
103-
datatype: str,
104-
report_type: str,
105-
ncols: int,
106-
nrows:int,
107-
dbx: str) -> None:
102+
def analytics_features(
103+
dataframe: str, datatype: str, report_type: str, ncols: int, nrows: int, dbx: str
104+
) -> None:
108105
endpoint = "https://packages.ydata.ai/ydata-profiling?"
109106
package_version = __version__
110107

@@ -136,13 +133,15 @@ def analytics_features(dataframe: str,
136133

137134
requests.get(request_message)
138135

136+
139137
def is_running_in_databricks():
140-
mask = 'DATABRICKS_RUNTIME_VERSION' in os.environ
141-
if 'DATABRICKS_RUNTIME_VERSION' in os.environ:
142-
return os.environ['DATABRICKS_RUNTIME_VERSION']
138+
mask = "DATABRICKS_RUNTIME_VERSION" in os.environ
139+
if "DATABRICKS_RUNTIME_VERSION" in os.environ:
140+
return os.environ["DATABRICKS_RUNTIME_VERSION"]
143141
else:
144142
return str(mask)
145143

144+
146145
def calculate_nrows(df):
147146
"""
148147
Calculates the approx. number of rows spark dataframes
@@ -152,10 +151,15 @@ def calculate_nrows(df):
152151
try:
153152
n_partitions = df.rdd.getNumPartitions()
154153

155-
nrows = df.rdd.mapPartitionsWithIndex(
156-
lambda idx, partition: [sum(1 for _ in partition)] if idx == 0 else [0]
157-
).collect()[0] * n_partitions
154+
nrows = (
155+
df.rdd.mapPartitionsWithIndex(
156+
lambda idx, partition: [sum(1 for _ in partition)] if idx == 0 else [0]
157+
).collect()[0]
158+
* n_partitions
159+
)
158160
except:
159-
nrows = 0 # returns 0 in case it was not possible to compute it from the partition
161+
nrows = (
162+
0 # returns 0 in case it was not possible to compute it from the partition
163+
)
160164

161165
return nrows

src/ydata_profiling/utils/logger.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
import pandas as pd
88

9-
from ydata_profiling.utils.common import (calculate_nrows,
10-
analytics_features,
11-
is_running_in_databricks)
9+
from ydata_profiling.utils.common import (
10+
analytics_features,
11+
calculate_nrows,
12+
is_running_in_databricks,
13+
)
1214

1315

1416
class ProfilingLogger(logging.Logger):
@@ -20,22 +22,26 @@ def info_def_report(self, df, timeseries: bool) -> None: # noqa: ANN001
2022
if isinstance(df, pd.DataFrame):
2123
dataframe = "pandas"
2224
report_type = "regular"
23-
nrows=len(df)
25+
nrows = len(df)
2426
elif df is None:
2527
dataframe = "pandas"
2628
report_type = "compare"
27-
nrows=len(df)
29+
nrows = len(df)
2830
else:
2931
dataframe = "spark"
3032
report_type = "regular"
31-
nrows=calculate_nrows(df)
33+
nrows = calculate_nrows(df)
3234

33-
dbx=is_running_in_databricks()
35+
dbx = is_running_in_databricks()
3436
datatype = "timeseries" if timeseries else "tabular"
3537

3638
analytics_features(
37-
dataframe=dataframe, datatype=datatype, report_type=report_type,
38-
nrows=nrows, ncols=ncols, dbx=dbx
39+
dataframe=dataframe,
40+
datatype=datatype,
41+
report_type=report_type,
42+
nrows=nrows,
43+
ncols=ncols,
44+
dbx=dbx,
3945
)
4046

4147
super().info(

0 commit comments

Comments
 (0)