def test_srsf_conversion(self): """Converts to srsf and pull backs""" initial = self.unimodal_samples(-1) converted = from_srsf(to_srsf(self.unimodal_samples), initial=initial) # Distances between original samples and s -> to_srsf -> from_srsf distances = np.diag(metric(converted, self.unimodal_samples)) np.testing.assert_allclose(distances, 0, atol=8e-3)
def test_from_srsf(self): """Test from srsf""" # Checks SRSF conversion srsf = from_srsf(self.dummy_sample) data_matrix = [[[0.], [-0.23449228], [-0.83464009], [-1.38200046], [-1.55623723], [-1.38200046], [-0.83464009], [-0.23449228], [0.]]] np.testing.assert_almost_equal(data_matrix, srsf.data_matrix)
def animate(i): if i < 100: p = i / 100 pp = 1 - p else: pp = (i - 100) / 100 p = 1 - pp #print(a,b,c, d) ff = from_srsf(p * q + pp * q2) line.set_data(ff.sample_points[0], ff.data_matrix.squeeze()) if i < 100: j = i else: j = 199 - i line.set_color(color[j]) return line,
q = to_srsf(fd) q2 = to_srsf(fd2) cmap = clr.LinearSegmentedColormap.from_list('custom cmap', ['C0','C1']) v = [.25, .5, .75] color = cmap(v) plt.figure("srsf-geodesic") q.plot(label="$q_1$", linewidth=2) q2.plot(label="$q_2$", linewidth=2) for m, c in zip(v, color): y = (1 - m)*q + m*q2 y.plot(color=c) plt.legend() plt.tight_layout() plt.figure("geodesic") fd.plot(label="$f_1$", linewidth=2) fd2.plot(label="$f_2$", linewidth=2) for m, c in zip(v, color): y = (1 - m)*q + m*q2 from_srsf(y).plot(color=c) plt.legend() plt.tight_layout() plt.show()