From 63e9e9c1efb169d4a5663f18c91224f248e407dd Mon Sep 17 00:00:00 2001 From: lachlangrose Date: Mon, 17 Aug 2026 14:17:32 +0930 Subject: [PATCH 1/3] ci: pin map2loop/visualisation release-please versions to fix bad auto-bump Neither package has a component-scoped release-please tag yet (they were only just added to the workspace in #301/#302), so release-please had no correct anchor for their next version and fell back to misreading one of the repo's old generic v1.6.5 LoopStructural tags as their baseline, proposing 1.6.5 for both in the open release PR instead of a proper minor bump from their real current versions (map2loop 3.3.1, loopstructuralvisualisation 0.1.17). One-time release-as pins to the correct next versions; remove once that release PR has merged and each package has its own release-please tag to anchor future bumps. --- release-please-config.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release-please-config.json b/release-please-config.json index 3dbcbcb2d..12d40ea0f 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -15,11 +15,13 @@ }, "packages/map2loop": { "release-type": "python", - "component": "map2loop" + "component": "map2loop", + "release-as": "3.4.0" }, "packages/loopstructural_visualisation": { "release-type": "python", - "component": "loopstructuralvisualisation" + "component": "loopstructuralvisualisation", + "release-as": "0.2.0" } } } From 181e813851c7e7311b0cc758f98eb0eee74aefd6 Mon Sep 17 00:00:00 2001 From: lachlangrose Date: Mon, 17 Aug 2026 17:27:44 +0930 Subject: [PATCH 2/3] fix: ensuring stratigraphic order is consistent between methods + adding test --- .../modelling/core/stratigraphic_column.py | 2 +- tests/unit/modelling/test_stratigraphic_column.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/LoopStructural/modelling/core/stratigraphic_column.py b/LoopStructural/modelling/core/stratigraphic_column.py index 4f4eb0033..48d5e0849 100644 --- a/LoopStructural/modelling/core/stratigraphic_column.py +++ b/LoopStructural/modelling/core/stratigraphic_column.py @@ -668,7 +668,7 @@ def get_isovalues(self) -> dict[str, float]: surface_values = {} for g in reversed(self.get_groups()): v = 0 - for u in g.units: + for u in reversed(g.units): surface_values[u.name] = {'value':v,'group':g.name,'colour':u.colour} v += u.thickness return surface_values diff --git a/tests/unit/modelling/test_stratigraphic_column.py b/tests/unit/modelling/test_stratigraphic_column.py index b10ed36e2..1f7fc2849 100644 --- a/tests/unit/modelling/test_stratigraphic_column.py +++ b/tests/unit/modelling/test_stratigraphic_column.py @@ -430,6 +430,20 @@ def test_get_isovalues(self): assert isovalues["B"]["value"] == 0 assert isovalues["B"]["group"] == "Group_0" + def test_get_isovalues_multi_unit_group(self): + # Isovalues must match update_unit_values: the base of the oldest + # unit in a group is 0, and each unit's thickness gives the base + # value of the next (younger) unit. + column = StratigraphicColumn() + column.clear(basement=False) + column.add_unit("A", thickness=10, id=0) + column.add_unit("B", thickness=5, id=1) + column.add_unit("C", thickness=3, id=2) + isovalues = column.get_isovalues() + assert isovalues["A"]["value"] == 0 + assert isovalues["B"]["value"] == 10 + assert isovalues["C"]["value"] == 15 + class TestOrderingAndUpdates: def test_update_order_reorders_elements(self): From 523b9de1e5bb68c8e0463c8d0aaa5d47381bb71b Mon Sep 17 00:00:00 2001 From: lachlangrose Date: Mon, 24 Aug 2026 13:05:18 +0930 Subject: [PATCH 3/3] fix: update get_isovalues method to accept 'where' parameter and add tests for top value retrieval --- .../modelling/core/_model_exporter.py | 2 +- .../modelling/core/stratigraphic_column.py | 17 +++++++++++++++-- .../modelling/test_stratigraphic_column.py | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/LoopStructural/modelling/core/_model_exporter.py b/LoopStructural/modelling/core/_model_exporter.py index 7bdfc679a..1e903d816 100644 --- a/LoopStructural/modelling/core/_model_exporter.py +++ b/LoopStructural/modelling/core/_model_exporter.py @@ -38,7 +38,7 @@ def get_stratigraphic_surfaces(model, units=None, bottoms=True): units = [] if model.stratigraphic_column is None: return [] - units = model.stratigraphic_column.get_isovalues() + units = model.stratigraphic_column.get_isovalues(where='bottom' if bottoms else 'top') units_for_group = {} for name, u in units.items(): if u['group'] not in model: diff --git a/LoopStructural/modelling/core/stratigraphic_column.py b/LoopStructural/modelling/core/stratigraphic_column.py index 48d5e0849..d202bea5b 100644 --- a/LoopStructural/modelling/core/stratigraphic_column.py +++ b/LoopStructural/modelling/core/stratigraphic_column.py @@ -661,16 +661,29 @@ def from_dict(cls, data): column.add_element(element) return column - def get_isovalues(self) -> dict[str, float]: + def get_isovalues(self, where: str = 'bottom') -> dict[str, float]: """ Returns a dictionary of isovalues for the stratigraphic units in the column. + + Parameters + ---------- + where : str, optional + 'bottom' (default) returns the value at the base of each unit. + 'top' returns the value at the top of each unit. """ + if where not in ('top', 'bottom'): + raise ValueError("Invalid 'where' argument. Use 'top' or 'bottom'.") surface_values = {} for g in reversed(self.get_groups()): v = 0 for u in reversed(g.units): - surface_values[u.name] = {'value':v,'group':g.name,'colour':u.colour} + base = v v += u.thickness + surface_values[u.name] = { + 'value': v if where == 'top' else base, + 'group': g.name, + 'colour': u.colour, + } return surface_values def plot(self,*, ax=None, **kwargs): diff --git a/tests/unit/modelling/test_stratigraphic_column.py b/tests/unit/modelling/test_stratigraphic_column.py index 1f7fc2849..db27518b8 100644 --- a/tests/unit/modelling/test_stratigraphic_column.py +++ b/tests/unit/modelling/test_stratigraphic_column.py @@ -444,6 +444,25 @@ def test_get_isovalues_multi_unit_group(self): assert isovalues["B"]["value"] == 10 assert isovalues["C"]["value"] == 15 + def test_get_isovalues_where_top_returns_unit_top(self): + # where='top' must give each unit's top, i.e. base + thickness -- + # the same value that where='bottom' (default) gives the next + # (younger) unit as its base. + column = StratigraphicColumn() + column.clear(basement=False) + column.add_unit("A", thickness=10, id=0) + column.add_unit("B", thickness=5, id=1) + column.add_unit("C", thickness=3, id=2) + isovalues = column.get_isovalues(where='top') + assert isovalues["A"]["value"] == 10 + assert isovalues["B"]["value"] == 15 + assert isovalues["C"]["value"] == 18 + + def test_get_isovalues_invalid_where_raises(self): + column = self._build_two_group_column() + with pytest.raises(ValueError): + column.get_isovalues(where="middle") + class TestOrderingAndUpdates: def test_update_order_reorders_elements(self):