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

Check groove parameters #306

Merged
merged 4 commits into from
Mar 29, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
- add validators to `rotation-1.0.0.yaml`
& `gas_component-1.0.0.yaml` [[#303]](https://github.com/BAMWelDX/weldx/pull/303)

### fixes

- prevent creation of `IsoBaseGroove` with negative parameters [[#306]](https://github.com/BAMWelDX/weldx/pull/306)

## 0.3.1 (21.03.2021)

Expand Down
10 changes: 10 additions & 0 deletions tests/asdf_tests/test_asdf_groove.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def test_asdf_groove_exceptions():
code_number="6.1.1",
).to_profile()

# negative parameter value
with pytest.raises(ValueError):
get_groove(
groove_type="VGroove",
workpiece_thickness=Q_(9, "mm"),
groove_angle=Q_(50, "deg"),
root_face=Q_(-4, "mm"),
root_gap=Q_(2, "mm"),
)


@pytest.mark.parametrize("groove", test_params.values(), ids=test_params.keys())
def test_cross_section(groove): # noqa
Expand Down
11 changes: 11 additions & 0 deletions weldx/welding/groove/iso_9692_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class IsoBaseGroove(metaclass=abc.ABCMeta):
_AREA_RASTER_WIDTH = 0.1
"""steers the area approximation of the groove in ~cross_sect_area."""

def __post_init__(self):
"""Make sure all parameters are valid after class init."""
for key, value in self.parameters().items():
if value < 0.0:
raise ValueError(f"Invalid value for parameter {key}={value:~}")

def parameters(self):
"""Return groove parameters as dictionary of quantities."""
return {k: v for k, v in self.__dict__.items() if isinstance(v, pint.Quantity)}
Expand Down Expand Up @@ -1719,6 +1725,11 @@ def get_groove(
root_face=Q_(3, "mm"),
root_gap=Q_(1, "mm"))
Raises
------
ValueError
When passing negative parameter values.
Notes
-----
Each groove type has a different set of attributes which are required. Only
Expand Down