def test_invalid_valid_sanitize(): # get_invalid and get_valid datasets = {} tri_verts = [[0, 0], [1, 0], [-0.5, 3**0.5 / 2], [-0.5, -3**0.5 / 2]] tri_edges_valid = [ [0, 1, 0], [1, 2, 0], [2, 0, 0], [0, 3, 1], [3, 1, 1], [1, 0, 1], [0, 2, 2], [2, 3, 2], [3, 0, 2], ] tri_edges_invalid = [ [0, 1, 0], [1, 2, 0], [2, 0, 0], [0, 3, 1], [3, 1, 1], [1, 0, 1], [0, 2, 2], [2, 3, 2], [3, 1, 2], ] # changed 0 to 1 to create an invalid face ## Epithelium whose faces are all valid ## datasets["edge"] = pd.DataFrame(data=np.array(tri_edges_valid), columns=["srce", "trgt", "face"]) datasets["edge"].index.name = "edge" datasets["face"] = pd.DataFrame(data=np.zeros((3, 2)), columns=["x", "y"]) datasets["face"].index.name = "face" datasets["vert"] = pd.DataFrame(data=np.array(tri_verts), columns=["x", "y"]) datasets["vert"].index.name = "vert" specs = config.geometry.planar_spec() eptm = Epithelium("valid", datasets, specs, coords=["x", "y"]) PlanarGeometry.update_all(eptm) ## Epithelium with invalid faces (last 3) datasets_invalid = datasets.copy() datasets_invalid["edge"] = pd.DataFrame(data=np.array(tri_edges_invalid), columns=["srce", "trgt", "face"]) datasets_invalid["edge"].index.name = "edge" eptm_invalid = Epithelium("invalid", datasets_invalid, specs, coords=["x", "y"]) PlanarGeometry.update_all(eptm_invalid) eptm.get_valid() eptm_invalid.get_valid() res_invalid_expect_all_false = eptm.get_invalid() res_invalid_expect_some_true = eptm_invalid.get_invalid() assert eptm.edge_df["is_valid"].all() assert not eptm_invalid.edge_df["is_valid"][6:].all() assert not res_invalid_expect_all_false.all() assert res_invalid_expect_some_true[6:].all() ### testing sanitize ### edges 6 to 9 should be removed. edge_df_before = eptm.edge_df.copy() edge_df_invalid_before = eptm_invalid.edge_df.copy() eptm.sanitize() eptm_invalid.sanitize() assert edge_df_before.equals(eptm.edge_df) assert edge_df_invalid_before[:6].equals(eptm_invalid.edge_df)
def test_invalid_valid_sanitize(): # get_invalid and get_valid datasets = {} tri_verts = [[0, 0], [1, 0], [-0.5, 3**0.5 / 2], [-0.5, -3**0.5 / 2]] tri_edges_valid = [[0, 1, 0], [1, 2, 0], [2, 0, 0], [0, 3, 1], [3, 1, 1], [1, 0, 1], [0, 2, 2], [2, 3, 2], [3, 0, 2]] tri_edges_invalid = [[0, 1, 0], [1, 2, 0], [2, 0, 0], [0, 3, 1], [3, 1, 1], [1, 0, 1], [0, 2, 2], [2, 3, 2], [3, 1, 2]] # changed 0 to 1 to create an invalid face ## Epithelium whose faces are all valid ## datasets['edge'] = pd.DataFrame(data=np.array(tri_edges_valid), columns=['srce', 'trgt', 'face']) datasets['edge'].index.name = 'edge' datasets['face'] = pd.DataFrame(data=np.zeros((3, 2)), columns=['x', 'y']) datasets['face'].index.name = 'face' datasets['vert'] = pd.DataFrame(data=np.array(tri_verts), columns=['x', 'y']) datasets['vert'].index.name = 'vert' specs = config.geometry.planar_spec() eptm = Epithelium('valid', datasets, specs, coords=['x', 'y']) PlanarGeometry.update_all(eptm) ## Epithelium with invalid faces (last 3) datasets_invalid = datasets.copy() datasets_invalid['edge'] = pd.DataFrame(data=np.array(tri_edges_invalid), columns=['srce', 'trgt', 'face']) datasets_invalid['edge'].index.name = 'edge' eptm_invalid = Epithelium('invalid', datasets_invalid, specs, coords=['x', 'y']) PlanarGeometry.update_all(eptm_invalid) eptm.get_valid() eptm_invalid.get_valid() res_invalid_expect_all_false = eptm.get_invalid() res_invalid_expect_some_true = eptm_invalid.get_invalid() assert eptm.edge_df['is_valid'].all() assert (not eptm_invalid.edge_df['is_valid'][6:].all()) assert (not res_invalid_expect_all_false.all()) assert res_invalid_expect_some_true[6:].all() ### testing sanitize ### edges 6 to 9 should be removed. edge_df_before = eptm.edge_df.copy() edge_df_invalid_before = eptm_invalid.edge_df.copy() eptm.sanitize() eptm_invalid.sanitize() assert edge_df_before.equals(eptm.edge_df) assert edge_df_invalid_before[:6].equals(eptm_invalid.edge_df)