Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions RATapi/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition:
contrast_background_params = []

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

for contrast in project.contrasts:
resolution = project.resolutions[project.resolutions.index(contrast.resolution)]
resolution = project.resolutions[contrast.resolution]
if resolution.type == TypeOptions.Data:
contrast_resolution_params.append(-1)
else:
Expand All @@ -160,7 +160,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition:
problem.resolutionParams = [param.value for param in project.resolution_parameters]
problem.contrastBulkIns = [project.bulk_in.index(contrast.bulk_in, True) for contrast in project.contrasts]
problem.contrastBulkOuts = [project.bulk_out.index(contrast.bulk_out, True) for contrast in project.contrasts]
problem.contrastQzshifts = [0] * len(project.contrasts) # This is marked as "to do" in RAT
problem.contrastQzshifts = [1] * len(project.contrasts) # This is marked as "to do" in RAT
problem.contrastScalefactors = [
project.scalefactors.index(contrast.scalefactor, True) for contrast in project.contrasts
]
Expand Down Expand Up @@ -239,9 +239,7 @@ def make_data_present(project: RATapi.Project) -> list[int]:
The "dataPresent" field of the problem input used in the compiled RAT code.

"""
return [
1 if project.data[project.data.index(contrast.data)].data.size != 0 else 0 for contrast in project.contrasts
]
return [1 if project.data[contrast.data].data.size != 0 else 0 for contrast in project.contrasts]


def check_indices(problem: ProblemDefinition) -> None:
Expand Down
2 changes: 1 addition & 1 deletion RATapi/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def model_post_init(self, __context: Any) -> None:
)
elif "Substrate Roughness" not in [name.title() for name in self.get_all_protected_parameters()["parameters"]]:
# If substrate roughness is included as a standard parameter replace it with a protected parameter
substrate_roughness_values = self.parameters[self.parameters.index("Substrate Roughness")].model_dump()
substrate_roughness_values = self.parameters["Substrate Roughness"].model_dump()
self.parameters.remove("Substrate Roughness")
self.parameters.insert(0, RATapi.models.ProtectedParameter(**substrate_roughness_values))

Expand Down