Skip to content

Commit b3452f3

Browse files
authored
Updates indices (#71)
* Applies use of strings for Classlist __getitem__ * Bug fix for qzshift index in inputs.py * Bug fix
1 parent 06ecccb commit b3452f3

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

RATapi/inputs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition:
128128
contrast_background_params = []
129129

130130
for contrast in project.contrasts:
131-
background = project.backgrounds[project.backgrounds.index(contrast.background)]
131+
background = project.backgrounds[contrast.background]
132132
if background.type == TypeOptions.Data:
133133
contrast_background_params.append(-1)
134134
else:
@@ -138,7 +138,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition:
138138
contrast_resolution_params = []
139139

140140
for contrast in project.contrasts:
141-
resolution = project.resolutions[project.resolutions.index(contrast.resolution)]
141+
resolution = project.resolutions[contrast.resolution]
142142
if resolution.type == TypeOptions.Data:
143143
contrast_resolution_params.append(-1)
144144
else:
@@ -160,7 +160,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition:
160160
problem.resolutionParams = [param.value for param in project.resolution_parameters]
161161
problem.contrastBulkIns = [project.bulk_in.index(contrast.bulk_in, True) for contrast in project.contrasts]
162162
problem.contrastBulkOuts = [project.bulk_out.index(contrast.bulk_out, True) for contrast in project.contrasts]
163-
problem.contrastQzshifts = [0] * len(project.contrasts) # This is marked as "to do" in RAT
163+
problem.contrastQzshifts = [1] * len(project.contrasts) # This is marked as "to do" in RAT
164164
problem.contrastScalefactors = [
165165
project.scalefactors.index(contrast.scalefactor, True) for contrast in project.contrasts
166166
]
@@ -239,9 +239,7 @@ def make_data_present(project: RATapi.Project) -> list[int]:
239239
The "dataPresent" field of the problem input used in the compiled RAT code.
240240
241241
"""
242-
return [
243-
1 if project.data[project.data.index(contrast.data)].data.size != 0 else 0 for contrast in project.contrasts
244-
]
242+
return [1 if project.data[contrast.data].data.size != 0 else 0 for contrast in project.contrasts]
245243

246244

247245
def check_indices(problem: ProblemDefinition) -> None:

RATapi/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def model_post_init(self, __context: Any) -> None:
285285
)
286286
elif "Substrate Roughness" not in [name.title() for name in self.get_all_protected_parameters()["parameters"]]:
287287
# If substrate roughness is included as a standard parameter replace it with a protected parameter
288-
substrate_roughness_values = self.parameters[self.parameters.index("Substrate Roughness")].model_dump()
288+
substrate_roughness_values = self.parameters["Substrate Roughness"].model_dump()
289289
self.parameters.remove("Substrate Roughness")
290290
self.parameters.insert(0, RATapi.models.ProtectedParameter(**substrate_roughness_values))
291291

0 commit comments

Comments
 (0)