Skip to content

Commit 8b06af4

Browse files
pre-commit-ci-lite[bot]klytje
authored andcommitted
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
1 parent d3d84a5 commit 8b06af4

30 files changed

+185
-185
lines changed

src/sas/qtgui/Calculators/Shape2SAS/Constraints.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def merge_text(current_text: str, parameter_text: str):
112112
return get_default(parameter_text)
113113

114114
new_lines = parameter_text.split("\n")
115-
# fit_param string is formatted as:
115+
# fit_param string is formatted as:
116116
# [
117117
# # header
118118
# ['name1', 'unit1', ...],
@@ -129,7 +129,7 @@ def merge_text(current_text: str, parameter_text: str):
129129
if name in old_names:
130130
entry = old_lines[old_names.index(name)+2]
131131
new_lines[i+2] = entry + ',' if entry[-1] != ',' else entry
132-
132+
133133
# remove old lines from the current text and insert the new ones in the middle
134134
current_text = "\n".join(current_text_lines[:start+1] + new_lines[2:-1] + current_text_lines[start+end:])
135135
return current_text
@@ -167,7 +167,7 @@ def expand_center_of_mass_pars(constraint: ast.Assign) -> list[ast.Assign]:
167167
"""Expand center of mass parameters to include all components."""
168168

169169
# check if this is a COM assignment we need to expand
170-
if (len(constraint.targets) != 1 or
170+
if (len(constraint.targets) != 1 or
171171
not isinstance(constraint.targets[0], ast.Name) or
172172
not isinstance(constraint.value, ast.Name)):
173173
return constraint
@@ -267,7 +267,7 @@ def extract_symbols(constraints: list[ast.AST]) -> tuple[list[str], list[str]]:
267267

268268
return lhs, rhs, lineno
269269

270-
def validate_params(params: ast.AST):
270+
def validate_params(params: ast.AST):
271271
if params is None:
272272
self.log_embedded_error("No parameters found in constraints text.")
273273
raise ValueError("No parameters found in constraints text.")
@@ -302,7 +302,7 @@ def validate_imports(imports: list[ast.ImportFrom | ast.Import]):
302302

303303
def mark_named_parameters(checkedPars: list[list[bool]], modelPars: list[str], symbols: set[str]):
304304
"""Mark parameters in the modelPars as checked if they are in symbols_lhs."""
305-
def in_symbols(par: str):
305+
def in_symbols(par: str):
306306
if par in symbols: return True
307307
if 'd' + par in symbols: return True
308308
return False

src/sas/qtgui/Calculators/Shape2SAS/DesignWindow.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,12 @@ def getPluginModel(self):
647647
modelProfile = self.getModelProfile(self.ifFitPar, conditionBool=checkedPars, conditionFitPar=parNames)
648648

649649
model_str, full_path = generate_plugin(
650-
modelProfile,
650+
modelProfile,
651651
[parNames, parVals],
652652
usertext,
653-
fitPar,
654-
Npoints,
655-
prPoints,
653+
fitPar,
654+
Npoints,
655+
prPoints,
656656
modelName
657657
)
658658

@@ -711,10 +711,10 @@ def getSimulatedSAXSData(self):
711711
Distr = getPointDistribution(Profile, N)
712712

713713
model = ModelSystem(
714-
PointDistribution=Distr,
715-
Stype=Stype, par=par,
716-
polydispersity=polydispersity,
717-
conc=conc,
714+
PointDistribution=Distr,
715+
Stype=Stype, par=par,
716+
polydispersity=polydispersity,
717+
conc=conc,
718718
sigma_r=sigma_r
719719
)
720720

src/sas/qtgui/Calculators/Shape2SAS/Tables/subunitTable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def onAdding(self):
512512
if row in subunitName.keys():
513513
paintedName = subunitName[row] + f"{to_column_name}" + " = "
514514
item = CustomStandardItem(
515-
paintedName, subunitUnits[row],
515+
paintedName, subunitUnits[row],
516516
subunitTooltip[row], subunitDefault_value[row],
517517
plot_callback=self.updatePlotCallback
518518
)
@@ -536,7 +536,7 @@ def onAdding(self):
536536
method = MethodType(attr, OptionLayout)
537537
name, defaultVal, units, tooltip, _, _ = method()
538538
item = CustomStandardItem(
539-
name[row] + f"{to_column_name}" + " = ", units[row],
539+
name[row] + f"{to_column_name}" + " = ", units[row],
540540
tooltip[row], defaultVal[row],
541541
plot_callback=self.updatePlotCallback
542542
)

src/sas/qtgui/Calculators/Shape2SAS/ViewerModel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def initialiseAxis(self):
147147

148148
def setAxis(self, x_range: (float, float), y_range: (float, float), z_range: (float, float)):
149149
"""Set axis for the model with equal aspect ratio"""
150-
150+
151151
# Calculate the overall range to ensure equal aspect ratio
152152
x_min, x_max = x_range
153153
y_min, y_max = y_range
@@ -156,10 +156,10 @@ def setAxis(self, x_range: (float, float), y_range: (float, float), z_range: (fl
156156
y_center = (y_min + y_max) / 2
157157
z_center = (z_min + z_max) / 2
158158
max_range = max(x_max - x_min, y_max - y_min, z_max - z_min)
159-
159+
160160
# Add some padding
161161
half_range = (max_range*1.1) / 2
162-
162+
163163
# Set equal ranges for all axes centered on their respective centers
164164
self.X_ax.setRange(x_center - half_range, x_center + half_range)
165165
self.Y_ax.setRange(y_center - half_range, y_center + half_range)

src/sas/sascalc/shape2sas/ExperimentalScattering.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class SimulatedScattering:
2626
I_err: np.ndarray
2727

2828
class IExperimental:
29-
def __init__(self,
30-
q: np.ndarray,
31-
I0: np.ndarray,
32-
I: np.ndarray,
29+
def __init__(self,
30+
q: np.ndarray,
31+
I0: np.ndarray,
32+
I: np.ndarray,
3333
exposure: float):
3434
self.q = q
3535
self.I0 = I0
@@ -73,7 +73,7 @@ def simulate_data(self) -> Vector2D:
7373
N = k * self.q # original expression from Sedlak2017 paper
7474

7575
qt = 1.4 # threshold - above this q value, the linear expression do not hold
76-
a = 3.0 # empirical constant
76+
a = 3.0 # empirical constant
7777
b = 0.6 # empirical constant
7878
idx = np.where(self.q > qt)
7979
N[idx] = k * qt * np.exp(-0.5 * ((self.q[idx] - qt) / b)**a)
@@ -83,7 +83,7 @@ def simulate_data(self) -> Vector2D:
8383
q_arb = 0.3
8484
if q_max <= q_arb:
8585
I_sed_arb = I_sed[-2]
86-
else:
86+
else:
8787
idx_arb = np.where(self.q > q_arb)[0][0]
8888
I_sed_arb = I_sed[idx_arb]
8989

@@ -116,4 +116,4 @@ def getSimulatedScattering(scalc: SimulateScattering) -> SimulatedScattering:
116116
Isim_class = IExperimental(scalc.q, scalc.I0, scalc.I, scalc.exposure)
117117
I_sim, I_err = Isim_class.simulate_data()
118118

119-
return SimulatedScattering(I_sim=I_sim, q=scalc.q, I_err=I_err)
119+
return SimulatedScattering(I_sim=I_sim, q=scalc.q, I_err=I_err)

src/sas/sascalc/shape2sas/HelperFunctions.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def qMethodsNames(name: str):
2222
"User_sampled": Qsampling.onUserSampledQ
2323
}
2424
return methods[name]
25-
25+
2626
def qMethodsInput(name: str):
2727
inputs = {
2828
"Uniform": {"qmin": 0.001, "qmax": 0.5, "Nq": 400},
@@ -50,7 +50,7 @@ def sinc(x) -> np.ndarray:
5050
function for calculating sinc = sin(x)/x
5151
numpy.sinc is defined as sinc(x) = sin(pi*x)/(pi*x)
5252
"""
53-
return np.sinc(x / np.pi)
53+
return np.sinc(x / np.pi)
5454

5555

5656
def get_max_dimension(x_list: np.ndarray, y_list: np.ndarray, z_list: np.ndarray) -> float:
@@ -76,11 +76,11 @@ def get_max_dimension(x_list: np.ndarray, y_list: np.ndarray, z_list: np.ndarray
7676
return max_l
7777

7878

79-
def plot_2D(x_list: np.ndarray,
80-
y_list: np.ndarray,
81-
z_list: np.ndarray,
82-
p_list: np.ndarray,
83-
Models: np.ndarray,
79+
def plot_2D(x_list: np.ndarray,
80+
y_list: np.ndarray,
81+
z_list: np.ndarray,
82+
p_list: np.ndarray,
83+
Models: np.ndarray,
8484
high_res: bool) -> None:
8585
"""
8686
plot 2D-projections of generated points (shapes) using matplotlib:
@@ -123,7 +123,7 @@ def plot_2D(x_list: np.ndarray,
123123
ax[0].set_title('pointmodel, (x,z), "front"')
124124

125125
## plot, perspective 2
126-
ax[1].plot(y[idx_pos], z[idx_pos], linestyle='none', marker='.', markersize=markersize)
126+
ax[1].plot(y[idx_pos], z[idx_pos], linestyle='none', marker='.', markersize=markersize)
127127
ax[1].plot(y[idx_neg], z[idx_neg], linestyle='none', marker='.', markersize=markersize, color='black')
128128
ax[1].plot(y[idx_nul], z[idx_nul], linestyle='none', marker='.', markersize=markersize, color='grey')
129129
ax[1].set_xlim(lim)
@@ -133,15 +133,15 @@ def plot_2D(x_list: np.ndarray,
133133
ax[1].set_title('pointmodel, (y,z), "side"')
134134

135135
## plot, perspective 3
136-
ax[2].plot(x[idx_pos], y[idx_pos], linestyle='none', marker='.', markersize=markersize)
136+
ax[2].plot(x[idx_pos], y[idx_pos], linestyle='none', marker='.', markersize=markersize)
137137
ax[2].plot(x[idx_neg], y[idx_neg], linestyle='none', marker='.', markersize=markersize, color='black')
138-
ax[2].plot(x[idx_nul], y[idx_nul], linestyle='none', marker='.', markersize=markersize, color='grey')
138+
ax[2].plot(x[idx_nul], y[idx_nul], linestyle='none', marker='.', markersize=markersize, color='grey')
139139
ax[2].set_xlim(lim)
140140
ax[2].set_ylim(lim)
141141
ax[2].set_xlabel('x')
142142
ax[2].set_ylabel('y')
143143
ax[2].set_title('pointmodel, (x,y), "bottom"')
144-
144+
145145
plt.tight_layout()
146146
if high_res:
147147
plt.savefig('points%s.png' % Model,dpi=600)
@@ -150,16 +150,16 @@ def plot_2D(x_list: np.ndarray,
150150
plt.close()
151151

152152

153-
def plot_results(q: np.ndarray,
154-
r_list: list[np.ndarray],
155-
pr_list: list[np.ndarray],
156-
I_list: list[np.ndarray],
157-
Isim_list: list[np.ndarray],
158-
sigma_list: list[np.ndarray],
159-
S_list: list[np.ndarray],
160-
names: list[str],
161-
scales: list[float],
162-
xscale_log: bool,
153+
def plot_results(q: np.ndarray,
154+
r_list: list[np.ndarray],
155+
pr_list: list[np.ndarray],
156+
I_list: list[np.ndarray],
157+
Isim_list: list[np.ndarray],
158+
sigma_list: list[np.ndarray],
159+
S_list: list[np.ndarray],
160+
names: list[str],
161+
scales: list[float],
162+
xscale_log: bool,
163163
high_res: bool) -> None:
164164
"""
165165
plot results for all models, using matplotlib:
@@ -174,7 +174,7 @@ def plot_results(q: np.ndarray,
174174
for (r, pr, I, Isim, sigma, S, model_name, scale) in zip (r_list, pr_list, I_list, Isim_list, sigma_list, S_list, names, scales):
175175
ax[0].plot(r,pr,zorder=zo,label='p(r), %s' % model_name)
176176

177-
if scale > 1:
177+
if scale > 1:
178178
ax[2].errorbar(q,Isim*scale,yerr=sigma*scale,linestyle='none',marker='.',label=r'$I_\mathrm{sim}(q)$, %s, scaled by %d' % (model_name,scale),zorder=1/zo)
179179
else:
180180
ax[2].errorbar(q,Isim*scale,yerr=sigma*scale,linestyle='none',marker='.',label=r'$I_\mathrm{sim}(q)$, %s' % model_name,zorder=zo)
@@ -220,10 +220,10 @@ def plot_results(q: np.ndarray,
220220
plt.close()
221221

222222

223-
def generate_pdb(x_list: list[np.ndarray],
224-
y_list: list[np.ndarray],
225-
z_list: list[np.ndarray],
226-
p_list: list[np.ndarray],
223+
def generate_pdb(x_list: list[np.ndarray],
224+
y_list: list[np.ndarray],
225+
z_list: list[np.ndarray],
226+
p_list: list[np.ndarray],
227227
Model_list: list[str]) -> None:
228228
"""
229229
Generates a visualisation file in PDB format with the simulated points (coordinates) and contrasts

src/sas/sascalc/shape2sas/Models.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def setAvailableSubunits(self):
146146
"sphere": Sphere,
147147
"ball": Sphere,
148148

149-
"hollow_sphere": HollowSphere,
150-
"Hollow sphere": HollowSphere,
149+
"hollow_sphere": HollowSphere,
150+
"Hollow sphere": HollowSphere,
151151

152152
"cylinder": Cylinder,
153153

@@ -170,7 +170,7 @@ def setAvailableSubunits(self):
170170

171171
"disc_ring": DiscRing,
172172
"Disc ring": DiscRing,
173-
173+
174174
"superellipsoid": SuperEllipsoid
175175
}
176176

@@ -211,14 +211,14 @@ def onAppendingPoints(x_new: np.ndarray,
211211

212212
@staticmethod
213213
def onCheckOverlap(
214-
x: np.ndarray,
215-
y: np.ndarray,
216-
z: np.ndarray,
217-
p: np.ndarray,
218-
rotation: list[float],
214+
x: np.ndarray,
215+
y: np.ndarray,
216+
z: np.ndarray,
217+
p: np.ndarray,
218+
rotation: list[float],
219219
rotation_point: list[float],
220-
com: list[float],
221-
subunitClass: object,
220+
com: list[float],
221+
subunitClass: object,
222222
dimensions: list[float]
223223
):
224224
"""check for overlap with previous subunits.
@@ -385,8 +385,8 @@ def getPointDistribution(prof: ModelProfile, Npoints):
385385
print(f" Subunit {i}: {subunit} with dimensions {prof.dimensions[i]} at COM {prof.com[i]}")
386386
print(f" Rotation: {prof.rotation[i]} at rotation point {prof.rotation_points[i]} with SLD {prof.p_s[i]}")
387387

388-
x_new, y_new, z_new, p_new, volume_total = GenerateAllPoints(Npoints, prof.com, prof.subunits,
389-
prof.dimensions, prof.rotation, prof.rotation_points,
388+
x_new, y_new, z_new, p_new, volume_total = GenerateAllPoints(Npoints, prof.com, prof.subunits,
389+
prof.dimensions, prof.rotation, prof.rotation_points,
390390
prof.p_s, prof.exclude_overlap).onGeneratingAllPointsSeparately()
391-
392-
return ModelPointDistribution(x=x_new, y=y_new, z=z_new, p=p_new, volume_total=volume_total)
391+
392+
return ModelPointDistribution(x=x_new, y=y_new, z=z_new, p=p_new, volume_total=volume_total)

src/sas/sascalc/shape2sas/PluginGenerator.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88

99
def generate_plugin(
10-
prof: ModelProfile,
10+
prof: ModelProfile,
1111
modelPars: list[list[str], list[str | float]],
12-
usertext: UserText,
12+
usertext: UserText,
1313
fitPar: list[str],
14-
Npoints: int,
15-
pr_points: int,
14+
Npoints: int,
15+
pr_points: int,
1616
file_name: str
1717
) -> tuple[str, Path]:
1818
"""Generates a theoretical scattering plugin model"""
@@ -34,7 +34,7 @@ def get_shape_symbols(symbols: tuple[set[str], set[str]], modelPars: list[list[s
3434
for shape in modelPars[0]: # iterate over shape names
3535
for symbol in shape[1:]: # skip shape name
3636
shape_symbols.add(symbol)
37-
37+
3838
# filter out user-defined symbols
3939
lhs_symbols, rhs_symbols = set(), set()
4040
for symbol in symbols[0]:
@@ -44,7 +44,7 @@ def get_shape_symbols(symbols: tuple[set[str], set[str]], modelPars: list[list[s
4444
for symbol in symbols[1]:
4545
if symbol in shape_symbols or symbol[1:] in shape_symbols:
4646
rhs_symbols.add(symbol)
47-
47+
4848
return lhs_symbols, rhs_symbols
4949

5050
def format_parameter_list(par: list[list[str | float]]) -> str:
@@ -185,12 +185,12 @@ def script_insert_constrained_parameters(symbols: set[str], modelPars: list[list
185185
return bool(text), "\n".join(text) # indentation for the function body
186186

187187
def generate_model(
188-
prof: ModelProfile,
188+
prof: ModelProfile,
189189
modelPars: list[list[str], list[str | float]],
190-
usertext: UserText,
190+
usertext: UserText,
191191
fitPar: list[str],
192-
Npoints: int,
193-
pr_points: int,
192+
Npoints: int,
193+
pr_points: int,
194194
model_name: str
195195
) -> str:
196196
"""Generates a theoretical model"""
@@ -286,5 +286,5 @@ def Iq({', '.join(fitPar)}):
286286
Iq.vectorized = True
287287
288288
''')
289-
290-
return model_str
289+
290+
return model_str

src/sas/sascalc/shape2sas/Shape2SAS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def check_input(input: float, default: float, name: str, i: int):
278278

279279
Theo_I = getTheoreticalScattering(
280280
TheoreticalScatteringCalculation(
281-
System=model,
281+
System=model,
282282
Calculation=Sim_par
283283
)
284284
)

0 commit comments

Comments
 (0)