Skip to content

Commit

Permalink
Merge pull request #415 from ThomasBouche/bugfix/select_one_sample
Browse files Browse the repository at this point in the history
Bugfix/select one sample
  • Loading branch information
ThomasBouche authored Jan 9, 2023
2 parents 8bda3b4 + be0c248 commit 0bac53d
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions shapash/webapp/smart_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,9 @@ def update_datatable(selected_data,
{"name": '_index_', "id": '_index_'},
{"name": '_predict_', "id": '_predict_'}] + \
[{"name": self.explainer.features_dict[i], "id": i} for i in self.explainer.x_init]
df = self.round_dataframe
elif ((ctx.triggered[0]['prop_id'] == 'prediction_picking.selectedData') and
(selected_data is not None)):
(selected_data is not None) and (len(selected_data) > 1)):
row_ids = []
# If some data have been selected in prediction picking graph
if selected_data is not None and len(selected_data) > 1:
Expand All @@ -1368,7 +1369,10 @@ def update_datatable(selected_data,
# If click on Apply filter
elif ((ctx.triggered[0]['prop_id'] == 'apply_filter.n_clicks') | (
(ctx.triggered[0]['prop_id'] == 'prediction_picking.selectedData') and
(selected_data is None))):
((selected_data is None))) | (
(ctx.triggered[0]['prop_id'] == 'prediction_picking.selectedData') and
(selected_data is not None and len(selected_data) == 1 and selected_data['points'][0]['curveNumber'] > 0)
)):
# get list of ID
feature_id = [id_feature[i]['index'] for i in range(len(id_feature))]
str_id = [id_str_modality[i]['index'] for i in range(len(id_str_modality))]
Expand Down Expand Up @@ -1538,7 +1542,11 @@ def update_feature_importance(label,
# If click on a single point on prediction picking, do nothing
elif ((ctx.triggered[0]['prop_id'] == 'prediction_picking.selectedData') and
(selected_data is not None) and (len(selected_data) == 1)):
pass
# If there is some filters applied
if (len([d['_index_'] for d in data]) != len(self.list_index)):
selection = [d['_index_'] for d in data]
else:
selection = None
# If we have dubble click on prediction picking to remove the selected subset
elif ((ctx.triggered[0]['prop_id'] == 'prediction_picking.selectedData') and
(selected_data is None)):
Expand Down Expand Up @@ -1754,17 +1762,20 @@ def update_feature_selector(feature,
# Zoom management to generate graph which have global axis
if len(self.components['graph']['global_feature_importance'].figure['data']) == 1:
self.subset = self.list_index
elif len(self.components['graph']['global_feature_importance'].figure['data']) == 2:
if feature['points'][0]['curveNumber'] == 0:
if selected_data is not None and len(selected_data) > 1:
row_ids = []
for p in selected_data['points']:
row_ids.append(p['customdata'])
self.subset = row_ids
elif (len(self.components['graph']['global_feature_importance'].figure['data']) == 2):
if feature is not None:
if feature['points'][0]['curveNumber'] == 0:
if selected_data is not None and len(selected_data) > 1:
row_ids = []
for p in selected_data['points']:
row_ids.append(p['customdata'])
self.subset = row_ids
else:
self.subset = [d['_index_'] for d in data]
else:
self.subset = [d['_index_'] for d in data]
self.subset = self.list_index
else:
self.subset = self.list_index
self.subset = [d['_index_'] for d in data]
else:
row_ids = []
if selected_data is not None and len(selected_data) > 1:
Expand Down

0 comments on commit 0bac53d

Please sign in to comment.