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
2 changes: 1 addition & 1 deletion API/enums/actions.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef actions < customEnum
% Ways in which a background can be included in a contrast.
% Ways in which a background can be included in a contrast.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
2 changes: 1 addition & 1 deletion API/enums/allowedTypes.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef allowedTypes < customEnum
% Ways of defining a background or resolution.
% Ways of defining a background or resolution.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
2 changes: 1 addition & 1 deletion API/enums/boundHandlingOptions.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef boundHandlingOptions < customEnum
% Options for bound handling in DREAM.
% Options for bound handling in DREAM.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
4 changes: 2 additions & 2 deletions API/enums/calculationTypes.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef calculationTypes < customEnum
% Types of calculation that can be performed by RAT.
methods (Static)
% Types of calculation that can be performed by RAT.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
2 changes: 1 addition & 1 deletion API/enums/coderEnums.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef coderEnums
% An Enum class which lets MATLAB Coder use Enums without redefinition or hardcoding.
% An Enum class which lets MATLAB Coder use Enums without redefinition or hardcoding.
properties (Constant)
actions = actions.toStruct()
allowedTypes = allowedTypes.toStruct()
Expand Down
2 changes: 1 addition & 1 deletion API/enums/displayOptions.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef displayOptions < customEnum
% The available options for terminal output.
% The available options for terminal output.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
4 changes: 2 additions & 2 deletions API/enums/errorCodes.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef errorCodes < customEnum
% Internal error codes for MATLAB Coder exceptions (see compile/exceptions/coderException.m).
methods (Static)
% Internal error codes for MATLAB Coder exceptions (see compile/exceptions/coderException.m).
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
4 changes: 2 additions & 2 deletions API/enums/eventTypes.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef eventTypes < customEnum
% Types of output event from a RAT run.
methods (Static)
% Types of output event from a RAT run.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
10 changes: 5 additions & 5 deletions API/enums/geometryOptions.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
classdef geometryOptions < customEnum
% Where the substrate roughness is placed.
%
% For air/substrate, it is placed at the end of the stack.
% For substrate/liquid, it is placed at the beginning of the stack.
methods (Static)
% Where the substrate roughness is placed.
%
% For air/substrate, it is placed at the end of the stack.
% For substrate/liquid, it is placed at the beginning of the stack.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
2 changes: 1 addition & 1 deletion API/enums/hydrationTypes.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef hydrationTypes < customEnum
% Options for the 'hydrate with' parameter of a Layer.
% Options for the 'hydrate with' parameter of a Layer.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
2 changes: 1 addition & 1 deletion API/enums/modelTypes.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef modelTypes < customEnum
% Types of layer model supported by RAT.
% Types of layer model supported by RAT.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
2 changes: 1 addition & 1 deletion API/enums/parallelOptions.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef parallelOptions < customEnum
% Ways in which the calculation can be parallelised.
% Ways in which the calculation can be parallelised.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
Expand Down
4 changes: 2 additions & 2 deletions API/enums/priorTypes.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef priorTypes < customEnum
% Prior distributions for parameters in Bayesian algorithms.
methods (Static)
% Prior distributions for parameters in Bayesian algorithms.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
4 changes: 2 additions & 2 deletions API/enums/procedures.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef procedures < customEnum
% The algorithms available in RAT.
methods (Static)
% The algorithms available in RAT.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
4 changes: 2 additions & 2 deletions API/enums/searchStrategy.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef searchStrategy < customEnum
% Strategies for generating base vectors in differential evolution.
methods (Static)
% Strategies for generating base vectors in differential evolution.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'), true);
end
Expand Down
4 changes: 2 additions & 2 deletions API/enums/supportedLanguages.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
classdef supportedLanguages < customEnum
% Languages for custom files.
methods (Static)
% Languages for custom files.
methods (Static)
function s = toStruct()
s = customEnum.toStruct(mfilename('class'));
end
Expand Down
36 changes: 1 addition & 35 deletions API/projectClass/customFileClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
options.functionName = obj.varTable{row, 3}{:};
end
options.language = validateOption(options.language, 'supportedLanguages', obj.invalidLanguageMessage).value;
obj.setName(row, options.name);
obj.setRowName(row, options.name);
obj.varTable{row, 2} = {obj.addFileExtension(options.filename, options.language)};
obj.varTable{row, 4} = {options.language};
obj.varTable{row, 5} = {obj.validatePath(options.path)};
Expand Down Expand Up @@ -344,40 +344,6 @@ function delete(obj)
end
end

methods(Access = protected)
function obj = setName(obj, row, name)
% Sets the name of an existing custom file entry.
%
% Examples
% --------
% To change the name of the second custom file in the table (custom file in row 2)
%
% >>> file.setName(2, 'custom file 1');
%
% To change the name of a custom file called 'custom file 1' to 'new custom file'
%
% >>> file.setName('custom file 1', 'new custom file');
%
% Parameters
% ----------
% row : string or char array or whole number
% If ``row`` is an integer, it is the row number of the custom file to update. If it is text,
% it is the name of the custom file to update.
% name : string or char array
% The new name of the custom file.

% Name must not be an existing name
existingNames = obj.varTable{:,1};
existingNames(row) = [];
if any(strcmpi(name,existingNames))
throw(exceptions.duplicateName('Duplicate custom file names are not allowed'));
end

% Set the relevant name
obj.varTable{row, 1} = {name};
end
end

methods(Access = private)
function path = validatePath(~, path)
% Validates custom file path exists.
Expand Down
45 changes: 3 additions & 42 deletions API/projectClass/dataClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@
[options.dataRange, options.simRange] = obj.validateData(options.data, options.dataRange, options.simRange);

if ~strcmp(options.name, obj.varTable{row, 1}{:})
nameChanged = obj.setName(row, options.name);
nameChanged.oldName = obj.varTable{row, 1};
nameChanged.newName = options.name;
obj.setRowName(row, options.name);
end
obj.varTable{row, 2} = {options.data};
obj.varTable{row, 3} = {options.dataRange};
Expand Down Expand Up @@ -272,47 +274,6 @@ function displayTable(obj)
end

methods(Access = protected)
function nameChanged = setName(obj, row, name)
% Sets the name of an existing dataset.
%
% Examples
% --------
% To change the name of the second dataset in the table (dataset in row 2)
%
% >>> nameChanged = data.setName(2, 'Data SMW');
%
% To change the name of a dataset called 'Data D20' to 'Data SMW'
%
% >>> nameChanged = data.setName('Data D20', 'Data SMW');
%
% Parameters
% ----------
% row : string or char array or whole number
% If ``row`` is an integer, it is the row number of the dataset to update. If it is text,
% it is the name of the dataset to update.
% name : string or char array
% The new name of the dataset.
%
% Returns
% -------
% nameChanged : struct
% A struct which contains the former name ``oldName`` and the new name ``newName`` of the dataset.
arguments
obj
row
name {mustBeTextScalar, mustBeNonempty}
end
existingNames = obj.getNames;
if any(strcmpi(name, existingNames))
throw(exceptions.duplicateName('Duplicate data names are not allowed'));
end

% Set the relevant name
nameChanged.oldName = obj.varTable{row, 1};
nameChanged.newName = name;
obj.varTable{row, 1} = {name};
end

function [dataRange, simRange] = validateData(~, data, dataRange, simRange)
% Checks the data and simulation ranges are valid. If any range is invalid,
% a warning is printed and the range is adjusted when possible.
Expand Down
Loading