Skip to content

Commit

Permalink
remove unnecessary __eq__ methods (now taken care of by more general …
Browse files Browse the repository at this point in the history
…AeroSandboxObject.__eq__ method).
  • Loading branch information
peterdsharpe committed Mar 30, 2024
1 parent b08bf07 commit 099229f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
32 changes: 0 additions & 32 deletions aerosandbox/geometry/airfoil/airfoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,38 +190,6 @@ def default_CM_function(alpha, Re, mach=0, deflection=0):
def __repr__(self) -> str:
return f"Airfoil {self.name} ({self.n_points()} points)"

def __eq__(self, other: "Airfoil") -> bool:
"""
Checks if two airfoils are equal. Two airfoils are equal if they have the same name, coordinates, and
polar functions.
Args:
other: The other airfoil to compare to.
Returns:
True if the two airfoils are equal, False otherwise.
"""
if other is self: # If they're the same object in memory, they're equal
return True

if not type(self) == type(other): # If the types are different, they're not equal
return False

# At this point, we know that the types are the same, so we can compare the attributes
if self.name != other.name: # If the names are different, they're not equal
return False

if self.coordinates.shape != other.coordinates.shape: # If the coordinates are different shapes, they're not equal
return False

try:
return np.allclose(
self.coordinates,
other.coordinates
)
except Exception:
return False

def to_kulfan_airfoil(self,
n_weights_per_side: int = 8,
N1: float = 0.5,
Expand Down
18 changes: 0 additions & 18 deletions aerosandbox/geometry/airfoil/kulfan_airfoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def __repr__(self) -> str:
return f"Airfoil {self.name} (Kulfan / CST parameterization)"

def __eq__(self, other: "KulfanAirfoil") -> bool:
if other is self: # If they're the same object in memory, they're equal
return True

if not type(self) == type(other): # If the types are different, they're not equal
return False

# At this point, we know that the types are the same, so we can compare the attributes
return all([
self.name == other.name,
np.allclose(self.lower_weights, other.lower_weights),
np.allclose(self.upper_weights, other.upper_weights),
np.allclose(self.leading_edge_weight, other.leading_edge_weight),
np.allclose(self.TE_thickness, other.TE_thickness),
np.allclose(self.N1, other.N1),
np.allclose(self.N2, other.N2),
])

@property
def kulfan_parameters(self):
return {
Expand Down

0 comments on commit 099229f

Please sign in to comment.