Skip to content

Commit

Permalink
fixed bug introduced by custom_drop function (now deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkchafin committed May 8, 2024
1 parent c158904 commit 05fd7da
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions src/resistnet/hall_of_fame.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def check_population(self, pop):
return

popDF = popDF.sort_values("fitness", ascending=False)
popDF = popDF.drop_duplicates(keep="first", ignore_index=True)
#popDF = popDF.drop_duplicates(keep="first", ignore_index=True)
popDF = self.drop_active_duplicates(popDF, self.variables)
popDF = popDF.reset_index(drop=True)
space = self.max_size - self.data.shape[0]
Expand Down Expand Up @@ -111,39 +111,8 @@ def _update_data_frame(self):
self.data = self.data.sort_values("fitness", ascending=False)
self.data = self.drop_active_duplicates(self.data, self.variables)
self.data = self.data.reset_index(drop=True)
self.custom_drop()
self.min_fitness = self.data["fitness"].min()

def custom_drop(self):
"""
Perform custom operations on the hall of fame data.
This method applies custom transformations and drops duplicates in the
data. For each variable, it updates the weight, trans, and shape
columns by multiplying them with the variable's value and performs
additional adjustments.
"""
for v in self.variables:
v_str = str(v)
self.data[f"{v_str}_weight"] = (
self.data[v_str] * self.data[f"{v_str}_weight"]
)
self.data[f"{v_str}_trans"] = (
self.data[v_str] * self.data[f"{v_str}_trans"]
)
self.data[f"{v_str}_shape"] = (
self.data[v_str] * self.data[f"{v_str}_shape"]
)
self.data[f"{v_str}_asym"] = (
self.data[v_str] * self.data[f"{v_str}_asym"]
)
temp = self.data[f"{v_str}_trans"]
temp[temp > 1] = 1
self.data[f"{v_str}_shape"] = self.data[v_str] * temp

self.data = self.data.drop_duplicates(keep="first", ignore_index=True)
self.data = self.data.reset_index(drop=True)

def printHOF(self, max_row=None, max_col=None):
"""
Print the hall of fame data sorted by fitness.
Expand Down

0 comments on commit 05fd7da

Please sign in to comment.