From 23f4acdc23a9a30ee5863f1ac975a240f04644eb Mon Sep 17 00:00:00 2001 From: Arbona Date: Mon, 13 Mar 2017 10:41:30 +0100 Subject: [PATCH 1/6] color --- ipyvolume/serialize.py | 18 +++++++++--------- ipyvolume/volume.py | 2 +- js/src/volume.js | 35 +++++++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/ipyvolume/serialize.py b/ipyvolume/serialize.py index a34f5c1a..fd7b8920 100644 --- a/ipyvolume/serialize.py +++ b/ipyvolume/serialize.py @@ -87,14 +87,14 @@ def array_to_binary_or_json(ar, obj=None): elif performance == 0: return array_to_json(ar, obj=obj) elif performance == 1: - ar = np.array(ar, dtype=np.float32) # this mode only support 'regular' arrays - #known_type = ["|u1", "|i1", " Date: Mon, 13 Mar 2017 10:57:20 +0100 Subject: [PATCH 2/6] removed some log --- js/src/volume.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/src/volume.js b/js/src/volume.js index bad19d4e..75eb6034 100644 --- a/js/src/volume.js +++ b/js/src/volume.js @@ -80,13 +80,11 @@ function numpy_buffer_to_array(buf) { } var shape = info.shape; - console.log(shape) if (shape.length == 2) { var ndata = new Array(shape[0]) for(var i = 0; i< shape[0]; i++){ ndata[i] = data.slice(i*shape[1],(i+1)*shape[1]) } - console.log(ndata[0][0]) } else if (shape.length == 3){ var ndata = new Array(shape[0]) @@ -100,7 +98,6 @@ function numpy_buffer_to_array(buf) { } } else { var ndata = data - console.log(data[0]) } return ndata; From 0fbc95972ee1e5873da4c2eaaac8b120b8852be8 Mon Sep 17 00:00:00 2001 From: Arbona Date: Tue, 14 Mar 2017 14:54:14 +0100 Subject: [PATCH 3/6] color --- ipyvolume/serialize.py | 2 +- js/src/volume.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ipyvolume/serialize.py b/ipyvolume/serialize.py index fd7b8920..e37a2a6c 100644 --- a/ipyvolume/serialize.py +++ b/ipyvolume/serialize.py @@ -91,7 +91,7 @@ def array_to_binary_or_json(ar, obj=None): if ar.dtype in known_type and len(ar.shape) <= 3: #ar = np.array(ar, dtype=np.float32) # this mode only support 'regular' arrays iobyte = StringIO() - np.save(iobyte, ar) + np.save(iobyte, np.copy(ar,order='C')) #The copy is to ensure the C order return iobyte.getvalue() else: return array_to_json(ar) diff --git a/js/src/volume.js b/js/src/volume.js index 75eb6034..b2ebadd5 100644 --- a/js/src/volume.js +++ b/js/src/volume.js @@ -551,7 +551,7 @@ var ScatterView = widgets.WidgetView.extend( { }, create_mesh: function() { console.log("previous values: ") - console.log(this.previous_values) + //console.log(this.previous_values) var geo = this.model.get("geo") console.log(geo) if(!geo) From 3377236bc9256b2b99db28227c6fa1acf1c2c31a Mon Sep 17 00:00:00 2001 From: Arbona Date: Wed, 15 Mar 2017 09:35:02 +0100 Subject: [PATCH 4/6] Color with performance = 1 --- ipyvolume/serialize.py | 6 +++++- ipyvolume/volume.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ipyvolume/serialize.py b/ipyvolume/serialize.py index a05661f8..9eacc38b 100644 --- a/ipyvolume/serialize.py +++ b/ipyvolume/serialize.py @@ -89,9 +89,13 @@ def array_to_binary_or_json(ar, obj=None): elif performance == 1: known_type = ["|u1", "|i1", " Date: Wed, 15 Mar 2017 10:52:56 +0100 Subject: [PATCH 5/6] Color with performance = 1 --- ipyvolume/volume.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipyvolume/volume.py b/ipyvolume/volume.py index a88299cd..0a651b0c 100644 --- a/ipyvolume/volume.py +++ b/ipyvolume/volume.py @@ -34,8 +34,8 @@ class Scatter(widgets.DOMWidget): Array(default_value=None,allow_none=True).tag(sync=True, **array_serialization)], default_value=0.1).tag(sync=True) size_selected = traitlets.Float(0.02).tag(sync=True) - color = traitlets.Union([Unicode().tag(sync=True), - Array(default_value=None,allow_none=True).tag(sync=True, **create_array_binary_serialization('color'))], + color = traitlets.Union([Array(default_value=None,allow_none=True).tag(sync=True, **create_array_binary_serialization('color')), + Unicode().tag(sync=True)], default_value="red").tag(sync=True) color_selected = traitlets.Unicode(default_value="white").tag(sync=True) geo = traitlets.Unicode('diamond').tag(sync=True) From ded32bcb050f6422bb07f4368a86f0268f98bb7a Mon Sep 17 00:00:00 2001 From: Arbona Date: Wed, 15 Mar 2017 11:00:38 +0100 Subject: [PATCH 6/6] Fixed for the possible the long error msg (if array is not a numpy array) by first checking for array and then float --- ipyvolume/volume.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipyvolume/volume.py b/ipyvolume/volume.py index 0a651b0c..aa3331e2 100644 --- a/ipyvolume/volume.py +++ b/ipyvolume/volume.py @@ -30,8 +30,8 @@ class Scatter(widgets.DOMWidget): vz = Array(default_value=None,allow_none=True).tag(sync=True, **create_array_binary_serialization('vz')) selected = Array(default_value=None,allow_none=True).tag(sync=True, **array_serialization) sequence_index = Integer(default_value=0).tag(sync=True) - size = traitlets.Union([traitlets.Float().tag(sync=True), - Array(default_value=None,allow_none=True).tag(sync=True, **array_serialization)], + size = traitlets.Union([Array(default_value=None,allow_none=True).tag(sync=True, **array_serialization), + traitlets.Float().tag(sync=True)], default_value=0.1).tag(sync=True) size_selected = traitlets.Float(0.02).tag(sync=True) color = traitlets.Union([Array(default_value=None,allow_none=True).tag(sync=True, **create_array_binary_serialization('color')),