From be8dad89a63f8bfccb41c8f5dfaad120249f2a16 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Fri, 10 Jan 2014 10:28:53 +0000 Subject: [PATCH] pickling now allways binary as well as protocol -1 --- GPy/core/parameterized.py | 11 +++-------- .../controllers/axis_event_controller.py | 8 ++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/GPy/core/parameterized.py b/GPy/core/parameterized.py index de1adaf86..0e08e2c02 100644 --- a/GPy/core/parameterized.py +++ b/GPy/core/parameterized.py @@ -31,14 +31,9 @@ def _get_param_names(self): # """ Override for which names to print out, when using print m """ # return self._get_param_names() - def pickle(self, filename, protocol=None): - if protocol is None: - if self._has_get_set_state(): - protocol = 0 - else: - protocol = -1 - with open(filename, 'w') as f: - cPickle.dump(self, f, protocol) + def pickle(self, filename, protocol=-1): + with open(filename, 'wb') as f: + cPickle.dump(self, f, protocol=protocol) def copy(self): """Returns a (deep) copy of the current model """ diff --git a/GPy/util/latent_space_visualizations/controllers/axis_event_controller.py b/GPy/util/latent_space_visualizations/controllers/axis_event_controller.py index afc92ab09..67e7a797e 100644 --- a/GPy/util/latent_space_visualizations/controllers/axis_event_controller.py +++ b/GPy/util/latent_space_visualizations/controllers/axis_event_controller.py @@ -114,8 +114,12 @@ def update_view(self, view, X, xmin, xmax, ymin, ymax): raise NotImplementedError('update view given in here') def get_grid(self): - xmin, xmax = self._compute_buffered(*self._x_lim) - ymin, ymax = self._compute_buffered(*self._y_lim) + if self._not_init: + xmin, xmax = self._compute_buffered(*self._x_lim) + ymin, ymax = self._compute_buffered(*self._y_lim) + else: + xmin, xmax = self._x_lim + ymin, ymax = self._y_lim x, y = numpy.mgrid[xmin:xmax:1j * self.resolution, ymin:ymax:1j * self.resolution] return numpy.hstack((x.flatten()[:, None], y.flatten()[:, None]))