def test_scale(): datasets_2d, specs = three_faces_sheet(zaxis=True) datasets = extrude(datasets_2d, method='translation') initial_cell_df = pd.DataFrame.from_dict({'cell':[0,1,2],\ 'x':[0.5, -1.0, 0.5],\ 'y':[8.660000e-01,-6.167906e-18,-8.6600000e-01],\ 'z':[-0.5, -0.5, -0.5],\ 'is_alive':[True, True, True], 'num_faces':[8,8,8], 'vol':[2.598,2.598,2.598]}).set_index('cell') x10_cell_df = pd.DataFrame.from_dict({'cell':[0,1,2],\ 'x':[5., -10.0, 5.],\ 'y':[8.660000e+00,-6.167906e-17,-8.6600000e+00],\ 'z':[-5., -5., -5.],\ 'is_alive':[True, True, True], 'num_faces':[8,8,8], 'vol':[2.598,2.598,2.598]}).set_index('cell') eptm = Epithelium('test_volume',datasets, specs, coords=['x','y','z']) BulkGeometry.update_all(eptm) scale(eptm, delta = 10.0, coords= ['x','y','z']) tolerance = 1e-16 assert all( (x10_cell_df[['x','y','z']] - eptm.cell_df[['x', 'y', 'z']])**2 < 1e-16)
def test_bulk_update_vol(): datasets_2d, specs = three_faces_sheet(zaxis=True) datasets = extrude(datasets_2d, method='translation') eptm = Epithelium('test_volume',datasets, specs, coords=['x','y','z']) BulkGeometry.update_all(eptm) expected_cell_df = pd.DataFrame.from_dict({'cell':[0,1,2],\ 'x':[0.5, -1.0, 0.5],\ 'y':[8.660000e-01,-6.167906e-18,-8.6600000e-01],\ 'z':[-0.5, -0.5, -0.5],\ 'is_alive':[True, True, True], 'num_faces':[8,8,8], 'vol':[2.598,2.598,2.598]}).set_index('cell') expected_face_centroids = pd.DataFrame.from_dict({'face':list(range(24)),\ 'x':[0.5, -1.0, 0.5, 0.5, -1.0, 0.5, 0.5,\ 1.25, 1.25, 0.5, -0.25, -0.25, \ -0.25, -1.0, -1.75, -1.75, -1.0, \ -0.25, -0.25, -0.25, 0.5, 1.25, \ 1.25, 0.5],\ 'y':[0.86599999999999999, 0.0,\ -0.86599999999999999, \ 0.86599999999999999, 0.0,\ -0.86599999999999999, 0.0, 0.433,\ 1.2989999999999999, 1.732,\ 1.2989999999999999, 0.433, 0.433,\ 0.86599999999999999, 0.433, -0.433,\ -0.86599999999999999, -0.433, -0.433,\ -1.2989999999999999, -1.732, \ -1.2989999999999999, -0.433, 0.0],\ 'z':[0.0, 0.0, 0.0, -1.0, -1.0, -1.0, \ -0.5, -0.5, -0.5, -0.5, -0.5, \ -0.5, -0.5, -0.5, -0.5, -0.5, \ -0.5, -0.5, -0.5, -0.5, -0.5, \ -0.5, -0.5, -0.5]}).set_index('face') ## only update class methods in BulkGeometry : update_vol, update_centroids tolerance = 1e-16 ## check volumes assert all( (expected_cell_df['vol'] - eptm.cell_df['vol'])**2 < tolerance) ## check centroids assert all( (expected_face_centroids - eptm.face_df.loc[:, ['x','y','z']])**2 < tolerance )
def test_update(): datasets_2d, specs = three_faces_sheet(zaxis=True) datasets = extrude(datasets_2d, method='translation') initial_cell_df = pd.DataFrame.from_dict({'cell':[0,1,2],\ 'x':[0.5, -1.0, 0.5],\ 'y':[8.660000e-01,-6.167906e-18,-8.6600000e-01],\ 'z':[-0.5, -0.5, -0.5],\ 'is_alive':[True, True, True], 'num_faces':[8,8,8], 'vol':[2.598,2.598,2.598]}).set_index('cell') eptm = Epithelium('test_volume',datasets, specs, coords=['x','y','z']) BulkGeometry.update_all(eptm)
def test_find_transitions(): sheet = Sheet.planar_sheet_3d("sheet", 5, 5, 1, 1) sheet.sanitize() datasets = extrude(sheet.datasets, method="translation") eptm = Monolayer("test_IHt", datasets, bulk_spec()) BulkGeometry.update_all(eptm) eptm.settings["threshold_length"] = 1e-3 IH_transition(eptm, 26) BulkGeometry.update_all(eptm) eptm.settings["threshold_length"] = 1e-2 ih, hi = find_rearangements(eptm) assert len(ih) == 0 assert len(hi) == 2 assert len(find_HIs(eptm)) face = eptm.face_df.index[-1] HI_transition(eptm, face) BulkGeometry.update_all(eptm) eptm.settings["threshold_length"] = 2e-1 ih, hi = find_rearangements(eptm) assert len(ih) == 1 assert len(hi) == 0 assert len(find_IHs(eptm))
def test_HI_transition(): sheet = Sheet.planar_sheet_3d("sheet", 5, 5, 1, 1) sheet.sanitize() datasets = extrude(sheet.datasets, method="translation") eptm = Monolayer("test_HIt", datasets, bulk_spec()) BulkGeometry.update_all(eptm) Nc, Nf, Ne, Nv = eptm.Nc, eptm.Nf, eptm.Ne, eptm.Nv eptm.settings["threshold_length"] = 1e-3 IH_transition(eptm, 26) BulkGeometry.update_all(eptm) face = eptm.face_df.index[-1] HI_transition(eptm, face) assert eptm.Nc == Nc assert eptm.Nf == Nf assert eptm.Ne == Ne assert eptm.Nv == Nv invalid = eptm.get_invalid() assert np.alltrue(1 - invalid) assert np.alltrue(eptm.edge_df["sub_vol"] > 0)
def test_IH_transition(): sheet = Sheet.planar_sheet_3d("sheet", 5, 5, 1, 1) sheet.sanitize() datasets = extrude(sheet.datasets, method="translation") eptm = Monolayer("test_IHt", datasets, bulk_spec()) BulkGeometry.update_all(eptm) Nc, Nf, Ne, Nv = eptm.Nc, eptm.Nf, eptm.Ne, eptm.Nv eptm.settings["threshold_length"] = 1e-3 IH_transition(eptm, 26) BulkGeometry.update_all(eptm) assert eptm.Nc == Nc assert eptm.Nf == Nf + 2 assert eptm.Ne == Ne + 12 assert eptm.Nv == Nv + 1 invalid = eptm.get_invalid() assert np.alltrue(1 - invalid) assert np.alltrue(eptm.edge_df["sub_vol"] > 0) assert (eptm.face_df[eptm.face_df.segment == "apical"].shape[0] == eptm.cell_df.shape[0])
def test_bulk_division(): cells = hexa_grid3d(4, 4, 6) datasets = from_3d_voronoi(Voronoi(cells)) specs = bulk_spec() bulk = Epithelium("bulk", datasets, specs) bulk.reset_topo() bulk.reset_index() bulk.sanitize() bulk.reset_topo() bulk.reset_index() cell_division(bulk, 4, BulkGeometry) dsets = hdf5.load_datasets(Path(stores_dir) / "with_4sided_cell.hf5") bulk = Monolayer("4", dsets) BulkGeometry.update_all(bulk) # daughter = cell_division(bulk, 12, BulkGeometry) with pytest.warns(UserWarning): cell_division(bulk, 4, BulkGeometry) assert bulk.validate()
def test_bulk_update_vol(): datasets_2d, _ = three_faces_sheet(zaxis=True) datasets = extrude(datasets_2d, method="translation") specs = config.geometry.bulk_spec() eptm = Epithelium("test_volume", datasets, specs, coords=["x", "y", "z"]) BulkGeometry.update_all(eptm) expected_cell_df = pd.DataFrame.from_dict({ "cell": [0, 1, 2], "x": [0.5, -1.0, 0.5], "y": [8.660000e-01, -6.167906e-18, -8.6600000e-01], "z": [-0.5, -0.5, -0.5], "is_alive": [True, True, True], "num_faces": [8, 8, 8], "vol": [2.598, 2.598, 2.598], }).set_index("cell") expected_face_centroids = pd.DataFrame.from_dict({ "face": list(range(24)), "x": [ 0.5, -1.0, 0.5, 0.5, -1.0, 0.5, 0.5, 1.25, 1.25, 0.5, -0.25, -0.25, -0.25, -1.0, -1.75, -1.75, -1.0, -0.25, -0.25, -0.25, 0.5, 1.25, 1.25, 0.5, ], "y": [ 0.86599999999999999, 0.0, -0.86599999999999999, 0.86599999999999999, 0.0, -0.86599999999999999, 0.0, 0.433, 1.2989999999999999, 1.732, 1.2989999999999999, 0.433, 0.433, 0.86599999999999999, 0.433, -0.433, -0.86599999999999999, -0.433, -0.433, -1.2989999999999999, -1.732, -1.2989999999999999, -0.433, 0.0, ], "z": [ 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, ], }).set_index("face") ## only update class methods in BulkGeometry : update_vol, update_centroids tolerance = 1e-16 ## check volumes assert all((expected_cell_df["vol"] - eptm.cell_df["vol"])**2 < tolerance) ## check centroids assert all((expected_face_centroids - eptm.face_df.loc[:, ["x", "y", "z"]])**2 < tolerance)