# -*- coding: utf-8 -*- """`liftexport.section_from_profile`: Solid or Sandwich from a measured thickness profile. The profiles here are the ones measured live on 2026-09-03 with `section_profile` (a 6 x 6 grid of thickness-axis lines): two insulated pieces read 3 / 4 / 4 and 4 / 4 / 3 in, a solid piece 8 in, where the per-solid extents had said 0-11 / 0-7 (no gap at all).""" import pytest from vibe import liftexport def test_three_four_four_is_a_sandwich(): out = liftexport.section_from_profile([(0.0, 3.0, 1), (7.0, 11.0, 0)]) assert out == {'section_type': 'Sandwich', 'wythe_top_in': 3.0, 'insulation_in': 4.0, 'wythe_bottom_in': 4.0} def test_four_four_three_keeps_top_and_bottom_apart(): out = liftexport.section_from_profile([(0.0, 4.0, 0), (8.0, 11.0, 1)]) assert out['wythe_top_in'] == 4.0 assert out['wythe_bottom_in'] == 3.0 assert out['insulation_in'] == 4.0 def test_one_interval_is_solid(): assert liftexport.section_from_profile([(0.0, 8.0, 0)]) == {} def test_empty_profile_is_could_not_tell(): assert liftexport.section_from_profile([]) == {} assert liftexport.section_from_profile(None) == {} def test_touching_solids_merge_into_one_pour(): # A ledge drawn as its own solid: 0-8 and 8-10 touch, no insulation. assert liftexport.section_from_profile([(0.0, 8.0, 0), (8.0, 10.0, 1)]) == {} def test_overlapping_intervals_merge(): assert liftexport.section_from_profile([(0.0, 8.0, 0), (6.0, 10.0, 1)]) == {} def test_hairline_gap_is_not_insulation(): assert liftexport.section_from_profile([(0.0, 4.0, 0), (4.3, 8.0, 1)]) == {} def test_three_layers_split_at_the_largest_gap(): # Wythe + a touching thickened zone, gap, wythe: the merge keeps the # thickened zone with its wythe and the split lands on the 4 in gap. out = liftexport.section_from_profile( [(0.0, 3.0, 0), (3.0, 4.0, 2), (8.0, 11.0, 1)]) assert out['wythe_top_in'] == 4.0 assert out['insulation_in'] == 4.0 assert out['wythe_bottom_in'] == 3.0 def test_zero_thickness_interval_is_ignored(): out = liftexport.section_from_profile( [(0.0, 3.0, 0), (5.0, 5.0, 2), (7.0, 11.0, 1)]) assert out['wythe_top_in'] == 3.0 assert out['wythe_bottom_in'] == 4.0 def test_unreadable_interval_is_could_not_tell(): assert liftexport.section_from_profile([('x', 3.0, 0), (7.0, 11.0, 1)]) == {}