Skip to content

Commit 38589bf

Browse files
committed
linting
1 parent 4a4ae27 commit 38589bf

3 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/resistnet/MLPE.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def objective(rho):
2727

2828
bounds = [(0.0001, 0.4999)]
2929
result = minimize(objective, self.rho, bounds=bounds,
30-
method='L-BFGS-B')
30+
method='L-BFGS-B')
3131
self.rho = result.x[0]
3232
return self.rho
3333

@@ -109,22 +109,22 @@ def MLPE(Y, X, scale=True):
109109

110110
# # Create the 'groups' column for the pairwise comparisons
111111
# ID['group'] = ID.apply(lambda row: f"{row['pop1']}", axis=1)
112-
112+
113113
# # Convert to DataFrame
114114
# data = pd.DataFrame({'x': x, 'y': y, 'group': ID['group']})
115-
115+
116116
# # # Fit mixed-effects model using Maximum Likelihood
117117
# # model = sm.MixedLM.from_formula("y ~ x", data, groups=data["group"],
118118
# exog_re=ZZ)
119119
# # result = model.fit(reml=False)
120-
120+
121121
# # # Fit the null model (intercept-only) using Maximum Likelihood
122122
# # null_model = sm.MixedLM.from_formula("y ~ 1", data,
123123
# groups=data["group"], exog_re=ZZ)
124124
# # null_result = null_model.fit(reml=False)
125-
125+
126126
# # # Calculate marginal R-squared
127127
# # var_fixed = np.var(result.fittedvalues)
128128
# # var_random = result.cov_re.iloc[0, 0]
129129
# # var_residual = result.scale
130-
# # marginal_r2 = var_fixed / (var_fixed + var_random + var_residual)
130+
# # marginal_r2 = var_fixed / (var_fixed + var_random + var_residual)

src/resistnet/model_optimisation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import traceback
22
import random
3-
import math
43
import pandas as pd
54
import numpy as np
65
from queue import Empty

src/resistnet/model_optimisation_ga.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Attributes:
2222
# seed (int): Seed for random number generator.
2323
# resistance_network (ResistanceNetwork): An instance of
24-
# ResistanceNetwork or subclass.
24+
# ResistanceNetwork or subclass
2525
# verbose (bool): Flag to control verbosity of output.
2626
# task_queue (Queue): Queue for tasks.
2727
# result_queue (Queue): Queue for results.
@@ -38,8 +38,8 @@
3838
# verbosity.
3939

4040
# Args:
41-
# resistance_network (ResistanceNetwork or subclass): The resistance
42-
# network to optimize.
41+
# resistance_network (ResistanceNetwork or subclass): The resistanc
42+
# network to optimize
4343
# seed (int): Seed for random number generator.
4444
# verbose (bool): Flag to control verbosity of output.
4545
# """
@@ -133,7 +133,8 @@
133133
# fixShape=False, min_weight=0.0, max_shape=None,
134134
# max_hof_size=100, tournsize=10, awsum=0.95, only_keep=True,
135135
# use_full=False, fixed_params=None,
136-
# out=None, plot=True, verbose=True, report_all=False, threads=1):
136+
# out=None, plot=True, verbose=True, report_all=False,
137+
# threads=1):
137138
# """
138139
# Runs the genetic algorithm for optimizing the ResistNet model.
139140

@@ -259,7 +260,8 @@
259260
# current_best = best
260261
# else:
261262
# current_best, fails = self.update_fails(
262-
# best, current_best, fails, deltaB, deltaB_perc,
263+
# best, current_best, fails, deltaB,
264+
# deltaB_perc,
263265
# minimize=True)
264266
# else:
265267
# worst = min(fits)
@@ -339,7 +341,7 @@
339341
# minimize (bool): Flag indicating minimization or maximization.
340342

341343
# Returns:
342-
# Tuple containing updated current best fitness score and fail count.
344+
# Tuple containing updated current best fitness score and failcount
343345
# """
344346
# cur = current_best
345347
# f = fails
@@ -398,7 +400,7 @@
398400

399401
# def init_ga_attributes(self):
400402
# """
401-
# Initializes the genetic algorithm's attributes and registers necessary
403+
# Initializes the genetic algorithm's attributes and registers necessar
402404
# functions with the toolbox, allowing dynamic specification of fixed
403405
# parameters per variable and attribute.
404406
# """
@@ -419,7 +421,7 @@
419421
# else:
420422
# return lambda: random.uniform(lower, upper)
421423

422-
# # Registering attribute generators for each variable and each attribute
424+
# # Registering attribute generators for each variable and each attribu
423425
# for var_name in self.resistance_network.variables:
424426
# self.toolbox.register(
425427
# f"{var_name}_sel", feature_generator(
@@ -477,7 +479,7 @@
477479
# self.toolbox.register(
478480
# "population", tools.initRepeat, list, self.toolbox.individual)
479481

480-
# # Evaluation, mating, mutation, and selection methods remain unchanged
482+
# # Evaluation, mating, mutation, and selection methods remain unchange
481483
# self.toolbox.register("evaluate", lambda ind: ind) # spoof
482484
# self.toolbox.register("mate", tools.cxTwoPoint)
483485
# self.toolbox.register("mutate", self.mutate)
@@ -486,7 +488,8 @@
486488

487489
# def mutate(self, individual):
488490
# """
489-
# Custom mutation function for an individual that aligns with the dynamic
491+
# Custom mutation function for an individual that aligns with the
492+
# dynamic
490493
# toolbox registration.
491494
# """
492495
# num_attributes = self.num_attributes
@@ -509,4 +512,4 @@
509512
# individual[idx_base + 3] = getattr(
510513
# self.toolbox, f"{var_name}_shape")()
511514

512-
# return individual,
515+
# return individual,

0 commit comments

Comments
 (0)