Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
frances-h committed Sep 22, 2023
1 parent 1d0ffd2 commit e41364a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
6 changes: 4 additions & 2 deletions sdmetrics/reports/multi_table/_properties/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def get_details(self, table_name=None):
return self.details.copy()

if self._num_iteration_case in ['relationship', 'inter_table_columns']:
table_rows = ((self.details['Parent Table'] == table_name) |
(self.details['Child Table'] == table_name))
table_rows = (
(self.details['Parent Table'] == table_name) |
(self.details['Child Table'] == table_name)
)
else:
table_rows = self.details['Table'] == table_name

Expand Down
41 changes: 30 additions & 11 deletions sdmetrics/reports/multi_table/_properties/inter_table_trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class InterTableTrends(BaseMultiTableProperty):
calculated and the final score represents the average of these measures across
all column pairs
"""

_num_iteration_case = 'inter_table_columns'

def get_score(self, real_data, synthetic_data, metadata, progress_bar=None):
Expand Down Expand Up @@ -104,6 +105,21 @@ def get_score(self, real_data, synthetic_data, metadata, progress_bar=None):
return self._compute_average()

def get_visualization(self, table_name=None):
"""Create a plot to show the inter table trends data.
Returns:
plotly.graph_objects._figure.Figure
Args:
table_name (str, optional):
Table to plot. Defaults to None.
Raises:
- ``ValueError`` if property has not been computed.
Returns:
plotly.graph_objects._figure.Figure
"""
if not self.is_computed:
raise ValueError(
'The property must be computed before getting a visualization.'
Expand All @@ -112,8 +128,10 @@ def get_visualization(self, table_name=None):

to_plot = self.details.copy()
if table_name is not None:
to_plot = to_plot[(to_plot['Parent Table'] == table_name) |
(to_plot['Child Table'] == table_name)]
to_plot = to_plot[
(to_plot['Parent Table'] == table_name) |
(to_plot['Child Table'] == table_name)
]

parent_cols = to_plot['Parent Table'] + '.' + to_plot['Column 1']
child_cols = to_plot['Child Table'] + '.' + to_plot['Column 2']
Expand Down Expand Up @@ -145,20 +163,21 @@ def get_visualization(self, table_name=None):
'Metric',
'Score',
'Real Correlation',
'Synthetic Correlation']
'Synthetic Correlation'
]
)

fig.update_yaxes(range=[0, 1])

fig.update_traces(
hovertemplate="<br>".join([
"%{x}",
"%{customdata[0]}",
"",
"Metric=%{customdata[1]}",
"Score=%{customdata[2]}",
"Real Correlation=%{customdata[3]}",
"Synthetic Correlation=%{customdata[4]}<extra></extra>"
hovertemplate='<br>'.join([
'%{x}',
'%{customdata[0]}',
'',
'Metric=%{customdata[1]}',
'Score=%{customdata[2]}',
'Real Correlation=%{customdata[3]}',
'Synthetic Correlation=%{customdata[4]}<extra></extra>'
])
)

Expand Down

0 comments on commit e41364a

Please sign in to comment.