<commit_before>// Define Plotly specific subclasses
function PlotlySelectionWidget() {
    SelectionWidget.apply(this, arguments);
}

function PlotlyScrubberWidget() {
    ScrubberWidget.apply(this, arguments);
}

// Let them inherit from the baseclasses
PlotlySelectionWidget.prototype = Object.create(SelectionWidget.prototype);
PlotlyScrubberWidget.prototype = Object.create(ScrubberWidget.prototype);

// Define methods to override on widgets
var PlotlyMethods = {
    init_slider : function(init_val){
		$.each(this.frames, $.proxy(function(index, frame) {
			this.frames[index] = JSON.parse(frame);
		}, this));
    },
    update : function(current){
		var data = this.frames[current];
		$.each(data, function(id, data) {
			var plot = $('#'+id)[0];
			plot.data = data.data;
			Plotly.redraw(plot);
			Plotly.relayout(plot, layout);
		});
    },
    dynamic_update : function(current){
		function callback(initialized, msg){
			/* This callback receives data from Python as a string
			   in order to parse it correctly quotes are sliced off*/
			if (msg.msg_type == "execute_result") {
				var data = msg.content.data['text/plain'].slice(1, -1);
				this.frames[current] = JSON.parse(data);
				this.update(current);
			}
		}
		if(!(current in this.frames)) {
			var kernel = IPython.notebook.kernel;
			callbacks = {iopub: {output: $.proxy(callback, this, this.initialized)}};<commit_msg>Further fix to plot updating in plotly widgets<commit_after>// Define Plotly specific subclasses
function PlotlySelectionWidget() {
    SelectionWidget.apply(this, arguments);
}

function PlotlyScrubberWidget() {
    ScrubberWidget.apply(this, arguments);
}

// Let them inherit from the baseclasses
PlotlySelectionWidget.prototype = Object.create(SelectionWidget.prototype);
PlotlyScrubberWidget.prototype = Object.create(ScrubberWidget.prototype);

// Define methods to override on widgets
var PlotlyMethods = {
    init_slider : function(init_val){
		$.each(this.frames, $.proxy(function(index, frame) {
			this.frames[index] = JSON.parse(frame);
		}, this));
    },
    update : function(current){
		var data = this.frames[current];
		$.each(data, function(id, data) {
			var plot = $('#'+id)[0];
			plot.data = data.data;
			plot.layout = data.layout;
			Plotly.relayout(plot, data.layout);
			Plotly.redraw(plot);
		});
    },
    dynamic_update : function(current){
		function callback(initialized, msg){
			/* This callback receives data from Python as a string
			   in order to parse it correctly quotes are sliced off*/
			if (msg.msg_type == "execute_result") {
				var data = msg.content.data['text/plain'].slice(1, -1);
				this.frames[current] = JSON.parse(data);
				this.update(current);
			}
		}
		if(!(current in this.frames)) {
			var kernel = IPython.notebook.kernel;
			callbacks = {iopub: {output: $.proxy(callback, this, this.initialized)}};
{'fraction_non_alphanumeric': 0.13731656184486374, 'fraction_numerical': 0.0020964360587002098, 'mean_word_length': 4.158558558558559, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2482199', 'n_tokens_mistral': 964, 'n_tokens_neox': 872, 'n_words': 210}