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

Correct get_coordinate_from_distance if zero value is passed to a named parameter #436

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
28 changes: 14 additions & 14 deletions src/ansys/motorcad/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,20 +1248,20 @@ def get_coordinate_from_distance(
Coordinate
Coordinate at distance along Line.
"""
if not distance and not fraction and not percentage:
if (distance is None) and (fraction is None) and (percentage is None):
raise Exception("You must provide either a distance, fraction or percentage.")

if distance and fraction:
if (distance is not None) and (fraction is not None):
warn("Both distance and fraction provided. Using distance.", UserWarning)
if distance and percentage:
if (distance is not None) and (percentage is not None):
warn("Both distance and percentage provided. Using distance.", UserWarning)

if not distance:
if fraction and percentage:
if distance is None:
if (fraction is not None) and (percentage is not None):
warn("Both fraction and percentage provided. Using fraction.", UserWarning)
if fraction:
if fraction is not None:
distance = self.length * fraction
elif percentage:
elif percentage is not None:
distance = self.length * (percentage / 100)

if ref_coordinate == self.end:
Expand Down Expand Up @@ -1450,20 +1450,20 @@ def get_coordinate_from_distance(
Coordinate
Coordinate at distance along Arc.
"""
if not distance and not fraction and not percentage:
if (distance is None) and (fraction is None) and (percentage is None):
raise Exception("You must provide either a distance, fraction or percentage.")

if distance and fraction:
if (distance is not None) and (fraction is not None):
warn("Both distance and fraction provided. Using distance.", UserWarning)
if distance and percentage:
if (distance is not None) and (percentage is not None):
warn("Both distance and percentage provided. Using distance.", UserWarning)

if not distance:
if fraction and percentage:
if distance is None:
if (fraction is not None) and (percentage is not None):
warn("Both fraction and percentage provided. Using fraction.", UserWarning)
if fraction:
if fraction is not None:
distance = self.length * fraction
elif percentage:
elif percentage is not None:
distance = self.length * (percentage / 100)

ref_coordinate_angle = atan2(
Expand Down
Loading