From 31774ce0f25a7dced7d37735eb01f36eeafbd500 Mon Sep 17 00:00:00 2001 From: "Jean Pierre Mandujano G." Date: Wed, 5 Aug 2026 00:03:16 -0500 Subject: [PATCH] test: cover from_processor with a stratigraphic column from_processor had no test coverage. The path broke when set_stratigraphic_column raised DeprecationWarning unconditionally (#296) and nothing caught it. The raise is gone in master since #300, so this regression test passes and guards the path from now on. --- tests/unit/input/test_data_processor.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/input/test_data_processor.py b/tests/unit/input/test_data_processor.py index 33a4a51d6..d37c17666 100644 --- a/tests/unit/input/test_data_processor.py +++ b/tests/unit/input/test_data_processor.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd +from LoopStructural import GeologicalModel from LoopStructural.modelling import ProcessInputData from LoopStructural.utils import rng @@ -14,3 +15,27 @@ def test_create_processor(): contacts=df, stratigraphic_order=stratigraphic_order, thicknesses=thicknesses ) assert (processor.data["val"].unique() == np.array([0.5, 0])).all() + + +def test_from_processor_populates_stratigraphic_column(): + """ + Regression test: from_processor crashed with a DeprecationWarning raised by + set_stratigraphic_column when assigning the processor's column to the model. + """ + df = pd.DataFrame(rng.random(size=(10, 3)), columns=["X", "Y", "Z"]) + df["name"] = [f"unit_{name % 2}" for name in range(10)] + stratigraphic_order = [("sg", ["unit_0", "unit_1", "basement"])] + thicknesses = {"unit_0": 1.0, "unit_1": 0.5} + processor = ProcessInputData( + contacts=df, + stratigraphic_order=stratigraphic_order, + thicknesses=thicknesses, + origin=np.zeros(3), + maximum=np.ones(3), + ) + + model = GeologicalModel.from_processor(processor) + + unit_names = [unit.name for unit in model.stratigraphic_column.order if hasattr(unit, "name")] + assert "unit_0" in unit_names + assert "unit_1" in unit_names