Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cmccomb committed Jan 2, 2024
1 parent f0ea2ff commit 66bba30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions trussme/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import trussme.visualize

from .truss import Truss, Goals
from trussme.truss import Truss, Goals


def report_to_str(truss: Truss, goals: Goals, with_figures: bool = True) -> str:
Expand All @@ -20,7 +20,7 @@ def report_to_str(truss: Truss, goals: Goals, with_figures: bool = True) -> str:
goals: Goals
The goals against which to evaluate the truss
with_figures: bool, default=True
Whether or not to include figures in the report
Whether to include figures in the report
Returns
-------
Expand Down
16 changes: 10 additions & 6 deletions trussme/truss.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ def analyze(self):
"""
Analyze the truss
Parameters
----------
None
Returns
-------
None
Expand Down Expand Up @@ -623,7 +619,7 @@ def read_json(file_name: str) -> Truss:
json_truss = json.load(file)

truss = Truss()
material_library: list[Material] = json_truss["materials"]
current_material_library: list[Material] = json_truss["materials"]

for joint in json_truss["joints"]:
truss.add_free_joint(joint["coordinates"])
Expand All @@ -632,7 +628,9 @@ def read_json(file_name: str) -> Truss:

for member in json_truss["members"]:
material: Material = next(
item for item in material_library if item["name"] == member["material"]
item
for item in current_material_library
if item["name"] == member["material"]
)
shape_params = member["shape"]["parameters"]
if member["shape"]["name"] == "pipe":
Expand All @@ -643,6 +641,12 @@ def read_json(file_name: str) -> Truss:
shape = Square(**dict(shape_params))
elif member["shape"]["name"] == "box":
shape = Box(**dict(shape_params))
else:
raise ValueError(
"Shape type '"
+ member["shape"]["name"]
+ "' is a custom type and not supported."
)
truss.add_member(
member["begin_joint"], member["end_joint"], material=material, shape=shape
)
Expand Down

0 comments on commit 66bba30

Please sign in to comment.