Skip to content

Commit

Permalink
Add drop_face to allow hole (issues DamCB#220 and DamCB#141) (assoc…
Browse files Browse the repository at this point in the history
…iate DamCB#221)
  • Loading branch information
sophietheis committed Feb 28, 2023
1 parent b226c31 commit 5047751
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
34 changes: 25 additions & 9 deletions tests/topology/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
condition_4ii,
remove_face,
)
from tyssue.topology.sheet_topology import cell_division, split_vert, type1_transition
from tyssue.topology.sheet_topology import cell_division, split_vert, type1_transition, drop_face


def test_condition4i():
Expand All @@ -40,7 +40,6 @@ def test_condition4ii():


def test_division():

h5store = os.path.join(stores_dir, "small_hexagonal.hf5")

datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
Expand All @@ -58,7 +57,6 @@ def test_division():


def test_t1_transition():

h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
specs = cylindrical_sheet()
Expand Down Expand Up @@ -91,7 +89,6 @@ def test_t1_at_border():


def test_split_vert():

datasets, specs = three_faces_sheet()
sheet = Sheet("3cells_2D", datasets, specs)
geom.update_all(sheet)
Expand Down Expand Up @@ -137,10 +134,29 @@ def test_merge_border_edges():
sheet.get_opposite()
sheet.sanitize(trim_borders=True)
assert (
sheet.edge_df[sheet.edge_df["opposite"] < 0]
.groupby("face")["opposite"]
.sum()
.min()
== -1
sheet.edge_df[sheet.edge_df["opposite"] < 0]
.groupby("face")["opposite"]
.sum()
.min()
== -1
)
assert not set(sheet.vert_df.index).difference(sheet.edge_df.srce)


def test_drop_face():
init_sheet = Sheet.planar_sheet_2d("planar", 6, 7, 1, 1)
init_sheet.sanitize(trim_borders=True, order_edges=True)
geom = PlanarGeometry
sheet = init_sheet.copy(deep_copy=True)

drop_face(sheet, 12, geom)
drop_face(sheet, 11, geom)

assert sheet.Nf == init_sheet.Nf - 2
assert sheet.Nv == init_sheet.Nv - 2
assert sheet.Ne == init_sheet.Ne - 14

sheet.get_opposite()
init_sheet.get_opposite()
assert sheet.edge_df[sheet.edge_df['opposite'] == -1].shape[0] == \
init_sheet.edge_df[init_sheet.edge_df['opposite'] == -1].shape[0] + 8
11 changes: 11 additions & 0 deletions tyssue/topology/sheet_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ def face_division(sheet, mother, vert_a, vert_b):
return daughter


def drop_face(eptm, face, geom, **kwargs):
"""
Removes the face indexed by "face" and all associated edges to allow holes
"""
edge = eptm.edge_df.loc[(eptm.edge_df['face'] == face)].index

eptm.remove(edge, **kwargs)
eptm.sanitize(trim_borders = True)
geom.update_all(eptm)


def resolve_t1s(sheet, geom, model, solver, max_iter=60):

l_th = sheet.settings["threshold_length"]
Expand Down

0 comments on commit 5047751

Please sign in to comment.