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

Add vector primitives #18

Merged
merged 34 commits into from
Aug 31, 2022
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bf0b6a7
Add 3D vector
Revathyvenugopal162 Aug 31, 2022
b90a6c8
Add properties for vector 3D
Revathyvenugopal162 Aug 31, 2022
2750a9d
Add typecasting in vector
Revathyvenugopal162 Aug 31, 2022
e205560
Add numpy as dependency
Revathyvenugopal162 Aug 31, 2022
3cfb019
Add vectorUV module
Revathyvenugopal162 Aug 31, 2022
eae4d68
Modify the 2D vector
Revathyvenugopal162 Aug 31, 2022
b1fae83
Add docstrings
Revathyvenugopal162 Aug 31, 2022
b41c470
Apply suggestions from code review
Revathyvenugopal162 Aug 31, 2022
0efd2a9
Update src/ansys/geometry/core/primitives/vector3D.py
Revathyvenugopal162 Aug 31, 2022
6dd967b
Add single vector module
Revathyvenugopal162 Aug 31, 2022
15129f5
Merge branch 'main' into feat/add-vector-primitives
Revathyvenugopal162 Aug 31, 2022
4173348
Add single vector module
Revathyvenugopal162 Aug 31, 2022
5eb9c5a
Add single vector module
Revathyvenugopal162 Aug 31, 2022
97b1c43
Merge branch 'main' into feat/add-vector-primitives
Revathyvenugopal162 Aug 31, 2022
c3db9f9
Add type error
Revathyvenugopal162 Aug 31, 2022
9028af7
Add docstrings
Revathyvenugopal162 Aug 31, 2022
b7770b1
Add basic test
Revathyvenugopal162 Aug 31, 2022
226c2ca
Modify basic test
Revathyvenugopal162 Aug 31, 2022
999ef85
Add test for normalize
Revathyvenugopal162 Aug 31, 2022
562d93a
Apply suggestions from code review
Revathyvenugopal162 Aug 31, 2022
c25e10b
Update src/ansys/geometry/core/primitives/vector.py
RobPasMue Aug 31, 2022
274c52b
UnitVectorXD proper implementation
RobPasMue Aug 31, 2022
1dcb3c8
Pre-commit check
RobPasMue Aug 31, 2022
1a1928d
Removing FirectionXD objects
RobPasMue Aug 31, 2022
0b84555
Pre-commit checks
RobPasMue Aug 31, 2022
0b0fe5d
Flexible metadata test
RobPasMue Aug 31, 2022
b5d431c
Add unitvector test
Revathyvenugopal162 Aug 31, 2022
aefb6a3
Pre-commit checks
RobPasMue Aug 31, 2022
daf62ce
Typo
RobPasMue Aug 31, 2022
9d434ff
Reordering and typo
RobPasMue Aug 31, 2022
1c34620
Pre-commit
RobPasMue Aug 31, 2022
4278806
Add error test for vector
Revathyvenugopal162 Aug 31, 2022
5ca8c59
Change test order
RobPasMue Aug 31, 2022
a1273bd
Check norm error
RobPasMue Aug 31, 2022
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
63 changes: 63 additions & 0 deletions tests/test_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,66 @@ def test_unit_vector_2d():
v3 = UnitVector2D([2, 1])
assert abs(round(v3.x, 3) - 0.894) <= DOUBLE_EPS
assert abs(round(v3.y, 3) - 0.447) <= DOUBLE_EPS


def test_vector2d_errors():
"""Testing multiple ``Vector2D`` errors."""
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved

with pytest.raises(ValueError, match="Vector2D must have two coordinates."):
Vector2D([1])

with pytest.raises(ValueError, match="The parameters of 'input' should be integer or float."):
Vector2D(["a", "b"])

# Create a point
v1 = Vector2D([1, 2])

# Test setter error checks
with pytest.raises(
ValueError, match="The parameter 'x' should be a float or an integer value."
):
v1.x = "x"

with pytest.raises(
ValueError, match="The parameter 'y' should be a float or an integer value."
):
v1.y = "y"

# Build a Vector3D and try to compare against it
with pytest.raises(ValueError, match="Comparison of"):
v2 = Vector3D([1, 5, 6])
assert v1 == v2


def test_vector3d_errors():
"""Testing multiple ``Vector3D`` errors."""
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved

with pytest.raises(ValueError, match="Vector3D must have three coordinates."):
Vector3D([1, 2])

with pytest.raises(ValueError, match="The parameters of 'inputs' should be integer or float."):
Vector3D(["a", "b", "c"])

# Create a point
v1 = Vector3D([1, 2, 3])

# Test setter error checks
with pytest.raises(
ValueError, match="The parameter 'x' should be a float or an integer value."
):
v1.x = "x"

with pytest.raises(
ValueError, match="The parameter 'y' should be a float or an integer value."
):
v1.y = "y"

with pytest.raises(
ValueError, match="The parameter 'z' should be a float or an integer value."
):
v1.z = "z"

# Build a Vector2D and try to compare against it
with pytest.raises(ValueError, match="Comparison of"):
v2 = Vector2D([1, 2])
assert v1 == v2