def projection_closed_curves_test_data(self): cells, _, _ = data_utils.load_cells() curves = [cell[:-10] for cell in cells[:5]] ambient_manifold = Euclidean(dim=2) smoke_data = [] for curve in curves: smoke_data += [ dict(ambient_manifold=ambient_manifold, curve=curve) ] return self.generate_tests(smoke_data)
def test_cartesian_to_polar_and_inverse(self): """Test that going back to cartesian works.""" cells, _, _ = data_utils.load_cells() curve = cells[0] metric = self.elastic_metric norms, args = metric.cartesian_to_polar(curve) result = metric.polar_to_cartesian(norms, args) expected = curve self.assertAllClose(result, expected, rtol=10000 * gs.rtol)
def test_elastic_dist(self): """Test shape and positivity.""" cells, _, _ = data_utils.load_cells() curve_1, curve_2 = cells[0][:10], cells[1][:10] metric = self.elastic_metric dist = metric.dist(curve_1, curve_2) result = dist.shape expected = () self.assertAllClose(result, expected) result = dist > 0 self.assertTrue(result)
def test_f_transform_and_inverse(self): """Test that the inverse is right.""" cells, _, _ = data_utils.load_cells() curve = cells[0] metric = self.elastic_metric f = metric.f_transform(curve) f_inverse = metric.f_transform_inverse(f, curve[0]) result = f.shape expected = (curve.shape[0] - 1, 2) self.assertAllClose(result, expected) result = f_inverse expected = curve self.assertAllClose(result, expected)
def test_projection_closed_curves(self): """Test that projecting the projection returns the projection and that the projection is a closed curve.""" planar_closed_curves = self.space_closed_curves_in_euclidean_2d cells, _, _ = data_utils.load_cells() curves = [cell[:-10] for cell in cells[:5]] for curve in curves: proj = planar_closed_curves.project(curve) expected = proj result = planar_closed_curves.project(proj) self.assertAllClose(result, expected) result = proj[-1, :] expected = proj[0, :] self.assertAllClose(result, expected, rtol=10 * gs.rtol)
def test_cells(self): """Test that cells belong to space of planar curves.""" cells, cell_lines, treatments = data_utils.load_cells() expected = 650 result = len(cells) self.assertAllClose(result, expected) result = len(cell_lines) self.assertAllClose(result, expected) result = len(treatments) self.assertAllClose(result, expected) planar_curves_space = DiscreteCurves(R2) result = planar_curves_space.belongs(cells) self.assertTrue(gs.all(result)) result = [line in ["dlm8", "dunn"] for line in cell_lines] self.assertTrue(gs.all(result)) result = [ treatment in ["control", "cytd", "jasp"] for treatment in treatments ] self.assertTrue(gs.all(result))
def cartesian_to_polar_and_inverse_test_data(self): cells, _, _ = data_utils.load_cells() curve = cells[0] smoke_data = [dict(a=1.0, b=1.0, curve=curve)] return self.generate_tests(smoke_data)
def elastic_dist_test_data(self): cells, _, _ = data_utils.load_cells() curve_1, curve_2 = cells[0][:10], cells[1][:10] smoke_data = [dict(a=1.0, b=0.5, curve_1=curve_1, curve_2=curve_2)] return self.generate_tests(smoke_data)
def f_transform_and_inverse_test_data(self): cells, _, _ = data_utils.load_cells() curve = cells[0] smoke_data = [dict(a=1.0, b=0.5, curve=curve)] return self.generate_tests(smoke_data)