Skip to content

Commit a557c74

Browse files
committed
feat: sync selection back to python
1 parent ec50ca8 commit a557c74

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

cvplot/cvplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ipywidgets as widgets
2-
from traitlets import Unicode, Dict
2+
from traitlets import Unicode, Dict, List
33
from sklearn.exceptions import NotFittedError
44
from joblib import delayed, Parallel, cpu_count
55
import numpy as np
@@ -32,6 +32,7 @@ class CVPlot(widgets.DOMWidget):
3232
_model_module_version = Unicode('^0.1.0').tag(sync=True)
3333

3434
value = Dict().tag(sync=True)
35+
selection = List().tag(sync=True)
3536

3637
def __init__(self, X, y, features, model, explainer=None, target_index=0, max=500, **kwargs):
3738
super().__init__(**kwargs)

js/lib/components/Contributions.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
this.$children.forEach(component => component.updatePossible(values))
9090
},
9191
updateSelected(values) {
92+
this.widget.model.set('selection', values)
93+
this.widget.model.save_changes()
9294
this.$children.forEach(component => component.updateSelected(values))
9395
}
9496
}

js/lib/cvplot.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ var Model = widgets.DOMWidgetModel.extend({
2929
_view_module : 'cvplot',
3030
_model_module_version : '0.1.0',
3131
_view_module_version : '0.1.0',
32-
value : {}
32+
value : {},
33+
selection : []
3334
})
3435
});
3536

@@ -52,8 +53,10 @@ var View = widgets.DOMWidgetView.extend({
5253
},
5354

5455
value_changed: function() {
56+
const widget = this
5557
const value = this.model.get('value')
5658
vm.$children[0].$nextTick(function() {
59+
this.$refs.contributions.widget = widget
5760
this.$refs.contributions.update(value)
5861
})
5962
}

0 commit comments

Comments
 (0)