def test_execute_division(): sheet = Sheet("emin", *three_faces_sheet()) geom.update_all(sheet) sheet.face_df["vol"] = 1.0 sheet.specs["face"]["prefered_vol"] = 1.0 sheet.face_df["prefered_vol"] = 1.0 sheet.face_df["id"] = sheet.face_df.index.values manager = EventManager("face") face_id = 1 event = (division, { "face_id": face_id, "growth_rate": 1.2, "critical_vol": 1.5 }) manager.current.append(event) V0 = sheet.face_df.loc[1, "prefered_vol"] manager.execute(sheet) manager.update() assert sheet.face_df.loc[1, "prefered_vol"] == V0 * 1.2 manager.execute(sheet) manager.update() assert sheet.face_df.loc[1, "prefered_vol"] == V0 * 1.44 sheet.face_df.loc[1, "vol"] *= 1.6 manager.execute(sheet) assert sheet.Nf == 4
def test_execute_constriction(): h5store = os.path.join(stores_dir, "small_hexagonal.hf5") datasets = load_datasets(h5store, data_names=["face", "vert", "edge"]) specs = config.geometry.cylindrical_sheet() sheet = Sheet("emin", datasets, specs) geom.update_all(sheet) sheet.settings["constriction"] = { "contractile_increase": 5, "critical_area": 5, "max_traction": 10, } sheet.face_df["id"] = sheet.face_df.index.values init_nb_cells = len(sheet.face_df) sheet.face_df["is_mesoderm"] = 0 sheet.vert_df["radial_tension"] = 0 manager = EventManager("face") face_id = 17 sheet.face_df.loc[face_id, "is_mesoderm"] = 1 sheet.settings["constriction"].update({"face_id": face_id}) initial_cell_event = (constriction, sheet.settings["constriction"]) manager.current.append(initial_cell_event) manager.execute(sheet) manager.update() assert len(manager.current) > 0 for i in range(20): manager.execute(sheet) manager.update() if len(sheet.face_df) == init_nb_cells: assert len(manager.current) > 0
def test_compute_gradient(): h5store = 'small_hexagonal.hf5' datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge']) specs = config.geometry.sheet_spec() sheet = Sheet('emin', datasets, specs) nondim_specs = config.dynamics.quasistatic_sheet_spec() dim_model_specs = model.dimentionalize(nondim_specs) sheet.update_specs(dim_model_specs) geom.update_all(sheet) isotropic_relax(sheet, nondim_specs) nrj_norm_factor = sheet.specs['settings']['nrj_norm_factor'] (grad_t, grad_c, grad_v_srce, grad_v_trgt) = model.compute_gradient(sheet, components=True) grad_t_norm = np.linalg.norm(grad_t, axis=0).sum() / nrj_norm_factor assert_almost_equal(grad_t_norm, 0.4497370048, decimal=DECIMAL) grad_c_norm = np.linalg.norm(grad_c, axis=0).sum() / nrj_norm_factor assert_almost_equal(grad_c_norm, 0.49692791, decimal=DECIMAL) grad_vs_norm = np.linalg.norm(grad_v_srce.dropna(), axis=0).sum() / nrj_norm_factor assert_almost_equal(grad_vs_norm, 0.3028136725, decimal=DECIMAL) grad_vt_norm = np.linalg.norm(grad_v_trgt.dropna(), axis=0).sum() / nrj_norm_factor assert_almost_equal(grad_vt_norm, 0.277320351, decimal=DECIMAL)
def test_execute_division(): sheet = Sheet('emin', *three_faces_sheet()) geom.update_all(sheet) sheet.face_df['vol'] = 1. sheet.specs['face']['prefered_vol'] = 1. sheet.face_df['prefered_vol'] = 1. sheet.face_df['id'] = sheet.face_df.index.values manager = EventManager('face') face_id = 1 event = (division, { 'face_id': face_id, 'growth_rate': 0.2, 'critical_vol': 1.5 }) manager.current.append(event) V0 = sheet.face_df.loc[1, 'prefered_vol'] manager.execute(sheet) manager.update() assert sheet.face_df.loc[1, 'prefered_vol'] == V0 * 1.2 manager.execute(sheet) manager.update() assert sheet.face_df.loc[1, 'prefered_vol'] == V0 * 1.44 sheet.face_df.loc[1, 'vol'] *= 1.6 manager.execute(sheet) assert sheet.Nf == 4
def test_execute_constriction(): h5store = os.path.join(stores_dir, 'small_hexagonal.hf5') datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge']) specs = config.geometry.cylindrical_sheet() sheet = Sheet('emin', datasets, specs) geom.update_all(sheet) sheet.settings['constriction'] = { 'contractile_increase': 5, 'critical_area': 5, 'max_traction': 10 } sheet.face_df['id'] = sheet.face_df.index.values init_nb_cells = len(sheet.face_df) sheet.face_df['is_mesoderm'] = 0 sheet.vert_df['radial_tension'] = 0 manager = EventManager('face') face_id = 17 sheet.face_df.loc[face_id, 'is_mesoderm'] = 1 sheet.settings['constriction'].update({'face_id': face_id}) initial_cell_event = (constriction, sheet.settings['constriction']) manager.current.append(initial_cell_event) manager.execute(sheet) manager.update() assert len(manager.current) > 0 for i in range(20): manager.execute(sheet) manager.update() if len(sheet.face_df) == init_nb_cells: assert len(manager.current) > 0
def test_split_vert(): datasets, specs = three_faces_sheet() sheet = Sheet("3cells_2D", datasets, specs) geom.update_all(sheet) split_vert(sheet, 0, multiplier=10) geom.update_all(sheet) assert sheet.Nv == 14 assert sheet.Ne == 20
def test_execute_apoptosis(): h5store = os.path.join(stores_dir, "small_hexagonal.hf5") datasets = load_datasets(h5store, data_names=["face", "vert", "edge"]) specs = config.geometry.cylindrical_sheet() sheet = Sheet("emin", datasets, specs) geom.update_all(sheet) sheet.settings["apoptosis"] = { "contractile_increase": 2.0, "critical_area": 0.1 } sheet.face_df["id"] = sheet.face_df.index.values init_nb_faces = len(sheet.face_df) manager = EventManager("face") face_id = 17 face_area = sheet.face_df.loc[face_id, "area"] initial_nbsides = sheet.face_df.loc[face_id, "num_sides"] sheet.settings["apoptosis"].update({"face_id": face_id}) initial_cell_event = (apoptosis, sheet.settings["apoptosis"]) manager.current.append(initial_cell_event) manager.execute(sheet) manager.update() assert len(manager.current) > 0 manager.execute(sheet) manager.update() sheet.settings["apoptosis"] = { "contractile_increase": 2.0, "critical_area": 2 * face_area, } manager.current.clear() sheet.settings["apoptosis"].update({"face_id": face_id}) modified_cell_event = (apoptosis, sheet.settings["apoptosis"]) manager.current.append(modified_cell_event) manager.execute(sheet) manager.update() next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, "face"), "num_sides"] i = 1 while next_nbsides > 4: assert next_nbsides == initial_nbsides - i assert len(manager.current) > 0 i = i + 1 manager.execute(sheet) manager.update() next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, "face"), "num_sides"] if i > 20: raise RecursionError manager.execute(sheet) manager.update() assert len(sheet.face_df) < init_nb_faces
def test_execute_apoptosis(): h5store = os.path.join(stores_dir, 'small_hexagonal.hf5') datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge']) specs = config.geometry.cylindrical_sheet() sheet = Sheet('emin', datasets, specs) geom.update_all(sheet) sheet.settings['apoptosis'] = { 'contractile_increase': 2.0, 'critical_area': 0.1 } sheet.face_df['id'] = sheet.face_df.index.values init_nb_faces = len(sheet.face_df) manager = EventManager('face') face_id = 17 face_area = sheet.face_df.loc[face_id, 'area'] initial_nbsides = sheet.face_df.loc[face_id, 'num_sides'] sheet.settings['apoptosis'].update({'face_id': face_id}) initial_cell_event = (apoptosis, sheet.settings['apoptosis']) manager.current.append(initial_cell_event) manager.execute(sheet) manager.update() assert len(manager.current) > 0 manager.execute(sheet) manager.update() sheet.settings['apoptosis'] = { 'contractile_increase': 2.0, 'critical_area': 2 * face_area } manager.current.clear() sheet.settings['apoptosis'].update({'face_id': face_id}) modified_cell_event = (apoptosis, sheet.settings['apoptosis']) manager.current.append(modified_cell_event) manager.execute(sheet) manager.update() next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, 'face'), 'num_sides'] i = 1 while next_nbsides > 4: assert next_nbsides == initial_nbsides - i assert len(manager.current) > 0 i = i + 1 manager.execute(sheet) manager.update() next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, 'face'), 'num_sides'] manager.execute(sheet) manager.update() assert len(sheet.face_df) < init_nb_faces
def test_face_rotation(): h5store = os.path.join(stores_dir, "small_hexagonal.hf5") datasets = load_datasets(h5store, data_names=["face", "vert", "edge"]) specs = config.geometry.cylindrical_sheet() sheet = Sheet("emin", datasets, specs) sgeom.update_all(sheet) face = 17 normal = sheet.edge_df[sheet.edge_df["face"] == face][sheet.ncoords].mean() rot = sgeom.face_rotation(sheet, face, 0) rotated = np.dot(rot, normal) np.testing.assert_allclose(rotated[:2], np.zeros(2), atol=1e-7)
def test_execute_contraction(): sheet = Sheet('emin', *three_faces_sheet()) geom.update_all(sheet) sheet.face_df['contractility'] = 1.12 sheet.face_df['id'] = sheet.face_df.index.values manager = EventManager('face') face_id = 1 event = (contraction, { 'face_id': face_id, 'contractile_increase': 0.2, 'critical_area': 1e-2 }) manager.current.append(event) manager.execute(sheet) manager.update() assert sheet.face_df.loc[face_id, 'contractility'] == 1.32
def test_type1_transition(): sheet = Sheet("emin", *three_faces_sheet()) geom.update_all(sheet) sheet.face_df["id"] = sheet.face_df.index.values manager = EventManager("face") face_id = 1 nb_neighbors_start = len(sheet.edge_df[sheet.edge_df["face"] == face_id]) edge_to_modify = sheet.edge_df[sheet.edge_df["face"] == face_id].index[0] sheet.edge_df.loc[edge_to_modify, "length"] = 0.2 event = (type1_transition, {"face_id": face_id, "critical_length": 0.3}) manager.current.append(event) manager.execute(sheet) manager.update() nb_neighbors_end = len(sheet.edge_df[sheet.edge_df["face"] == face_id]) assert nb_neighbors_end == nb_neighbors_start - 1
def test_rotations(): h5store = os.path.join(stores_dir, "small_hexagonal.hf5") datasets = load_datasets(h5store, data_names=["face", "vert", "edge"]) specs = config.geometry.cylindrical_sheet() sheet = Sheet("emin", datasets, specs) sgeom.update_all(sheet) sheet.sanitize() sgeom.update_all(sheet) sgeom.center(sheet) assert sgeom.face_rotations(sheet, method='normal', output_as='edge').shape[0] == sheet.Ne assert sgeom.face_rotations(sheet, method='normal', output_as='face').shape[0] == sheet.Nf assert sgeom.face_rotations(sheet, method='svd', output_as='edge').shape[0] == sheet.Ne assert sgeom.face_rotations(sheet, method='svd', output_as='face').shape[0] == sheet.Nf
def test_type1_transition(): sheet = Sheet('emin', *three_faces_sheet()) geom.update_all(sheet) sheet.face_df['id'] = sheet.face_df.index.values manager = EventManager('face') face_id = 1 nb_neighbors_start = len(sheet.edge_df[sheet.edge_df['face'] == face_id]) edge_to_modify = sheet.edge_df[sheet.edge_df['face'] == face_id].index[0] sheet.edge_df.loc[edge_to_modify, 'length'] = 0.2 event = (type1_transition, {'face_id': face_id, 'critical_length': 0.3}) manager.current.append(event) manager.execute(sheet) manager.update() nb_neighbors_end = len(sheet.edge_df[sheet.edge_df['face'] == face_id]) assert nb_neighbors_end == nb_neighbors_start - 1
def test_compute_energy(): h5store = os.path.join(stores_dir, "small_hexagonal.hf5") datasets = load_datasets(h5store, data_names=["face", "vert", "edge"]) specs = config.geometry.cylindrical_sheet() sheet = Sheet("emin", datasets, specs) nondim_specs = config.dynamics.quasistatic_sheet_spec() dim_model_specs = model.dimensionalize(nondim_specs) sheet.update_specs(dim_model_specs, reset=True) geom.update_all(sheet) Et, Ec, Ev = model.compute_energy(sheet, full_output=True) assert_almost_equal(Et.mean(), 0.02458566846202479, decimal=DECIMAL) assert_almost_equal(Ec.mean(), 0.08638339061549484, decimal=DECIMAL) assert_almost_equal(Ev.mean(), 0.06277441190064434, decimal=DECIMAL) energy = model.compute_energy(sheet, full_output=False) assert_almost_equal(energy, 15.040138762574534, decimal=DECIMAL)
def test_execute_contraction(): sheet = Sheet("emin", *three_faces_sheet()) geom.update_all(sheet) sheet.face_df["contractility"] = 1.12 sheet.face_df["id"] = sheet.face_df.index.values manager = EventManager("face") face_id = 1 event = ( contraction, { "face_id": face_id, "contractile_increase": 0.2, "critical_area": 1e-2 }, ) manager.current.append(event) manager.execute(sheet) manager.update() assert sheet.face_df.loc[face_id, "contractility"] == 1.32
def test_compute_energy(): h5store = 'small_hexagonal.hf5' datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge']) specs = config.geometry.cylindrical_sheet() sheet = Sheet('emin', datasets, specs) nondim_specs = config.dynamics.quasistatic_sheet_spec() dim_model_specs = model.dimentionalize(nondim_specs) sheet.update_specs(dim_model_specs) geom.update_all(sheet) isotropic_relax(sheet, nondim_specs) Et, Ec, Ev = model.compute_energy(sheet, full_output=True) assert_almost_equal(Et.mean(), 0.02301937, decimal=DECIMAL) assert_almost_equal(Ec.mean(), 0.15260879, decimal=DECIMAL) assert_almost_equal(Ev.mean(), 0.03189850, decimal=DECIMAL) energy = model.compute_energy(sheet, full_output=False) assert_almost_equal(energy, 12.9049416411, decimal=DECIMAL) assert_almost_equal(energy/sheet.face_df.is_alive.sum(), 0.3226, decimal=2)