ComputationalScienceLaboratory / ODE-Test-Problems

A MATLAB suite of initial value problems
https://computationalsciencelaboratory.github.io/ODE-Test-Problems/
MIT License
9 stars 3 forks source link

Testing enhancement #57

Closed AndreyAPopov closed 1 year ago

AndreyAPopov commented 1 year ago

I am in the process of reworking the tests and adding more.

The derivative code is very much a work-in-progress, so it is not much to look at at the moment.

AndreyAPopov commented 1 year ago

Alright, this seems to be in a good place now. It uses asserts, and fails if anything wrong happens. I also optimised the runtime.

Steven-Roberts commented 1 year ago

A simpler way to load all the presets:

function presets = getPresets()

presets = arrayfun(@constructPreset, dir('+otp/*/+presets/*.m'), 'UniformOutput', false);

end

function preset = constructPreset(file)

[~, presetName, ~] = fileparts(file.name);
folders = strsplit(file.folder, filesep)
problemName = folders{end-1};
preset = eval(sprintf('otp.%s.presets.%s', problemName(2:end), presetName));

end
AndreyAPopov commented 1 year ago

A simpler way to load all the presets:

function presets = getPresets()

presets = arrayfun(@constructPreset, dir('+otp/*/+presets/*.m'), 'UniformOutput', false);

end

function preset = constructPreset(file)

[~, presetName, ~] = fileparts(file.name);
folders = strsplit(file.folder, filesep)
problemName = folders{end-1};
preset = eval(sprintf('otp.%s.presets.%s', problemName(2:end), presetName));

end

This doesn't work in general. I'm trying to generalize it to when the working dir is not src

Got it working now