Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse points between shapes #839

Merged
merged 4 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions paramak/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,11 @@ def points(self):
return self._points

@points.setter
def points(self, values):

def points(self, values_in):
if values_in is None:
values = values_in
else:
values = values_in[:]
if values is not None:
if not isinstance(values, list):
raise ValueError("points must be a list")
Expand Down
6 changes: 4 additions & 2 deletions tests/test_Reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,9 +1229,11 @@ def test_export_h5m_with_pymoab_without_plasma(self):

assert Path('RotateStraightShape.stl').is_file()
assert Path('plasma.stl').is_file() is False
my_reactor.export_h5m_with_pymoab(include_plasma=True, filename='with_plasma.h5m')
my_reactor.export_h5m_with_pymoab(
include_plasma=True, filename='with_plasma.h5m')
assert Path('plasma.stl').is_file()
assert Path('with_plasma.h5m').stat().st_size > Path('no_plasma.h5m').stat().st_size
assert Path('with_plasma.h5m').stat().st_size > Path(
'no_plasma.h5m').stat().st_size

def test_export_h5m_with_pymoab_from_manifest_file(self):
"""exports a h5m file when shapes_and_components is set to a string"""
Expand Down
16 changes: 16 additions & 0 deletions tests/test_Shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,5 +819,21 @@ def check_correct_error_is_rasied():
self.assertRaises(ValueError, check_correct_error_is_rasied)


def test_reuse_points():
"""Checks that points can be reused between shapes"""
points = [
(100, 0, "straight"),
(200, 0, "straight"),
(250, 50, "straight"),
(200, 100, "straight"),
]
paramak.Shape(
points=points
)
paramak.Shape(
points=points
)


if __name__ == "__main__":
unittest.main()