Skip to content

Added utilities for saving and loading RasCAL2 files....#431

Open
arwelHughes wants to merge 4 commits intoRascalSoftware:masterfrom
arwelHughes:saveR2
Open

Added utilities for saving and loading RasCAL2 files....#431
arwelHughes wants to merge 4 commits intoRascalSoftware:masterfrom
arwelHughes:saveR2

Conversation

@arwelHughes
Copy link
Collaborator

No description provided.

problem = jsonToProject(projectFile);

% If there is a second argument, also load results..
if nargout > 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arwelHughes This does not convert controls.json is this intentional?

@StephenNneji StephenNneji force-pushed the saveR2 branch 2 times, most recently from cf6e22d to 366ddcb Compare February 23, 2026 15:20
Copy link
Collaborator

@abuts abuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It not to for me to make suggestions on code quality at this stage of a project, but IMHO, cd within a function is a very bad practice. It is usually ok to do cd on top level tests ensuring onCleanup returns to intial folder in any case, but cd within a routine usually causes bunch of maintenance problem on a long run. to/from json insides look also a bit crude.

Code works and does the job. There are 2 bugs and 1 suggestion within the test suite itself.

Comment on lines 58 to 63
result2 = jsonToResults("test.json");

props = properties(result);
for i = 1:length(props)
testCase.verifyEqual(result.(props{i}), result2.(props{i}));
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request:
This may be previous contribution, but this test tests nothing. Structure contains no properties.
row 60 should be:

            props = fieldnames(result);

And tests are failing if you do this. Seems on shape only but...

Comment on lines +101 to +102
for i = 1:length(props)
% verifies the problem name, model type and geometry
Copy link
Collaborator

@abuts abuts Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request if I understand it correctly:
I am puzzled. Why this loop? Nothing inside it depends on i or props -- you just run the same check 16 times. Should loop be removed?

All prop check is correctly perfromed at rows 120-124.

Test between for and end partially repeats 120-124 but ok, this way of testing may be more beneficial or clear, but why to run it in a loop?

evalc(scriptName);

controls = controlsClass();
[~, project, result] = evalc('RAT(problem, controls);');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:
I can vageuly understand and accept why one would use evalc in 85, though IMHO function handle would be much better. But in 88! Why?
Why to use:

[~, project, result] =  evalc('RAT(problem, controls);');

instead of just:

 [project, result] =  RAT(problem, controls);

It works faster and much more clear code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants