fix(ga): Suppress divide-by-zero warning in NumPy solver #17
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
||||
[project]
|
||||
# --- Core Metadata ---
|
||||
name = "polysolve"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
authors = [
|
||||
{ name="Jonathan Rampersad", email="jonathan@jono-rams.work" },
|
||||
]
|
||||
|
||||
@@ -295,6 +295,7 @@ class Function:
|
||||
y_calculated = np.polyval(self.coefficients, solutions)
|
||||
error = y_calculated - y_val
|
||||
|
||||
with np.errstate(divide='ignore'):
|
||||
ranks = np.where(error == 0, np.finfo(float).max, np.abs(1.0 / error))
|
||||
|
||||
# Sort solutions by fitness (descending)
|
||||
@@ -345,6 +346,7 @@ class Function:
|
||||
# After all generations, do one last ranking to find the best solutions
|
||||
y_calculated = np.polyval(self.coefficients, solutions)
|
||||
error = y_calculated - y_val
|
||||
with np.errstate(divide='ignore'):
|
||||
ranks = np.where(error == 0, np.finfo(float).max, np.abs(1.0 / error))
|
||||
sorted_indices = np.argsort(-ranks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user