Skip to content

r1_to_project_class fails on some of the RasCAL-1 demo projects #93

@alexhroom

Description

@alexhroom

r1_to_project_class cannot successfully convert the 8 contrast monolayer example from RasCAL-1 or the motofit benchmark example, both of which produce the error:

>>> r1_to_project_class('Monolayer_8_contrasts.mat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rec93639/Code/python-RAT/RATapi/utils/convert.py", line 208, in r1_to_project_class
    [
  File "/home/rec93639/Code/python-RAT/RATapi/utils/convert.py", line 211, in <listcomp>
    thickness=params[thickness - 1].name,
TypeError: unsupported operand type(s) for -: 'str' and 'int'

nor the double bilayer volume model (although this one may be an issue with the actual MAT judging by the error message:

>>> r1_to_project_class('double_bilayer_volume_model.mat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rec93639/Code/python-RAT/RATapi/utils/convert.py", line 116, in r1_to_project_class
    back_params = read_param("back_param_names", "backs_constr", "backs", "backgrounds_fityesno")
  File "/home/rec93639/Code/python-RAT/RATapi/utils/convert.py", line 83, in read_param
    [
  File "/home/rec93639/Code/python-RAT/RATapi/utils/convert.py", line 84, in <listcomp>
    Parameter(
  File "/home/rec93639/Code/python-RAT/.venv/lib/python3.10/site-packages/pydantic/main.py", line 176, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Parameter
  Value error, value 3.0506581195417703e-12 is not within the defined range: 5e-08 <= value <= 7e-06 [type=value_error, input_value={'name': 'Background para...loat64(7e-06), 'fit': 0}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/value_error

nor the spline test:

>>> r1_to_project_class('splineTest.mat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rec93639/Code/python-RAT/RATapi/utils/convert.py", line 42, in r1_to_project_class
    layer_model = LayerModels(layer_model)
  File "/usr/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: 'Custom XY Profile' is not a valid LayerModels

The remaining examples run successfully. Improve the robustness of the converter and maybe add the remaining RasCAL-1 demo projects as test cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions