Datasets:
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
Tags:
structural-engineering
structural-analysis
formal-verification
exact-arithmetic
symbolic-execution
theorem-proving
Download tests/test_sections.py from tailot/lingologos-struc: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/datasets/tailot/lingologos-struc/resolve/main/tests/test_sections.py
- Command line
-
hf download hf://datasets/tailot/lingologos-struc/tests/test_sections.py
-
curl -L -o test_sections.py https://huggingface.co/datasets/tailot/lingologos-struc/resolve/main/tests/test_sections.py
2.27 kB
| """A section is read the same way by both readers and its properties are computed twice.""" | |
| from fractions import Fraction | |
| import pytest | |
| from lgstruc import parse_a, parse_b, sections, tree | |
| RECTANGLE = "properties section rect 1/5 2/5" | |
| STACK = ("properties section shapes [ rect 1/10 3/5 0 ; rect 1/4 1/20 7/20 ; " | |
| "rect 1/4 1/20 -7/20 ]") | |
| def test_the_two_readers_agree_on_a_rectangle(): | |
| left = parse_a.parse(RECTANGLE) | |
| right = parse_b.parse(RECTANGLE) | |
| assert tree.canon(left) == tree.canon(right) | |
| def test_the_two_readers_agree_on_a_stack(): | |
| left = parse_a.parse(STACK) | |
| right = parse_b.parse(STACK) | |
| assert tree.canon(left) == tree.canon(right) | |
| def test_rectangle_by_theorems(): | |
| table = sections.by_theorems(sections.build(parse_a.parse(RECTANGLE)[1])) | |
| assert table["area"] == Fraction(2, 25) | |
| assert table["centroid"] == 0 | |
| assert table["inertia"] == Fraction(2, 1875) | |
| assert table["modulus"] == Fraction(2, 375) | |
| assert table["statical"] == Fraction(1, 250) | |
| assert table["thickness"] == Fraction(1, 5) | |
| assert table["top"] == Fraction(1, 5) | |
| assert table["bottom"] == Fraction(1, 5) | |
| def test_the_two_section_roads_give_the_same_numbers(): | |
| for sentence in (RECTANGLE, STACK): | |
| shape = parse_a.parse(sentence)[1] | |
| figure = sections.build(shape) | |
| left = sections.by_theorems(figure) | |
| right = sections.by_integration(figure) | |
| assert sections.agree(left, right) == [] | |
| def test_stacked_i_section_by_hand(): | |
| figure = sections.build(parse_a.parse(STACK)[1]) | |
| table = sections.by_theorems(figure) | |
| assert table["area"] == Fraction(17, 200) | |
| assert table["centroid"] == 0 | |
| assert table["inertia"] == Fraction(4673, 960000) | |
| assert table["statical"] == Fraction(71, 8000) | |
| assert table["thickness"] == Fraction(1, 10) | |
| assert table["top"] == Fraction(3, 8) | |
| def test_a_rectangle_with_no_side_is_refused(): | |
| with pytest.raises(Exception): | |
| sections.build(("rect", Fraction(0), Fraction(1, 5))) | |
| def test_a_decimal_and_its_ratio_are_the_same_number(): | |
| left = parse_a.parse("properties section rect 0.2 0.4") | |
| right = parse_b.parse("properties section rect 1/5 2/5") | |
| assert tree.canon(left) == tree.canon(right) | |