[tests working now?]

This commit is contained in:
mzwiessele 2015-10-07 00:52:47 +01:00
parent 5290e4bf0e
commit 7ebdc698f6
34 changed files with 42 additions and 33 deletions

View file

@ -52,7 +52,7 @@ def _plot_latent_scatter(canvas, X, visible_dims, labels, marker, num_samples, p
Tango.reset()
X, labels = subsample_X(X, labels, num_samples)
scatters = []
generate_colors = 'color' not in kwargs
generate_colors = 'color' not in kwargs
for x, y, z, this_label, _, m in scatter_label_generator(labels, X, visible_dims, marker):
update_not_existing_kwargs(kwargs, pl.defaults.latent_scatter)
if generate_colors:
@ -89,7 +89,7 @@ def plot_latent_scatter(self, labels=None,
labels = np.ones(self.num_data)
legend = False
else:
legend = find_best_layout_for_subplots(len(np.unique(labels)))
legend = find_best_layout_for_subplots(len(np.unique(labels)))[1]
scatters = _plot_latent_scatter(canvas, X, sig_dims, labels, marker, num_samples, projection=projection, **kwargs)
if projection == '3d':
return pl.show_canvas(canvas, dict(scatter=scatters), legend=legend,
@ -126,9 +126,9 @@ def plot_latent_inducing(self,
if 'color' not in kwargs:
kwargs['color'] = 'white'
canvas, kwargs = pl.get_new_canvas(projection=projection, **kwargs)
X, _, _ = get_x_y_var(self)
labels = np.ones(self.num_data)
scatters = _plot_latent_scatter(canvas, X, sig_dims, labels, marker, num_samples, projection=projection, **kwargs)
Z = self.Z.values
labels = np.array(['inducing'] * Z.shape[0])
scatters = _plot_latent_scatter(canvas, Z, sig_dims, labels, marker, num_samples, projection=projection, **kwargs)
if projection == '3d':
return pl.show_canvas(canvas, dict(scatter=scatters), legend=legend,
xlabel='latent dimension %i' % input_1,

View file

@ -138,7 +138,6 @@ def scatter_label_generator(labels, X, visible_dims, marker=None):
for lab in labels:
if not lab in ulabels:
ulabels.append(lab)
if marker is not None:
marker = itertools.cycle(list(marker))
else:
@ -154,19 +153,20 @@ def scatter_label_generator(labels, X, visible_dims, marker=None):
except:
input_1 = visible_dims
input_2 = input_3 = None
for ul in ulabels:
if type(ul) is np.string_:
this_label = ul
elif type(ul) is np.int64:
this_label = 'class %i' % ul
else:
from numbers import Number
if isinstance(ul, str):
try:
this_label = unicode(ul)
except NameError:
#python3
this_label = ul
elif isinstance(ul, Number):
this_label = 'class {!s}'.format(ul)
else:
this_label = ul
if marker is not None:
m = next(marker)