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

Warn instead of failing if coil area is zero #78

Merged
merged 1 commit into from
Mar 19, 2023
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
7 changes: 5 additions & 2 deletions freegs/coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import numpy as np
import numbers
from shapely.geometry import Point
import warnings


class AreaCurrentLimit:
Expand Down Expand Up @@ -253,11 +254,13 @@ def area(self):
The cross-section area of the coil in m^2
"""
if isinstance(self._area, numbers.Number):
assert self._area > 0
if not self._area > 0:
warnings.warn(f"Coil area {self._area:3.2f} <= 0")
return self._area
# Calculate using functor
area = self._area(self)
assert area > 0
if not area > 0:
warnings.warn(f"Coil area {area:3.2f} <= 0")
return area

@area.setter
Expand Down