Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the upcrossing analysis functions in MATLAB #151

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

MShabara
Copy link

This PR is related to the uncrossing analysis utilities:
1- The upcrossing functions were added.
2- The upcrossing_Test unit test is added.

@MShabara MShabara changed the title Adding the uncrossing analysis functions coded in MATLAB Adds the uncrossing analysis functions in MATLAB Dec 16, 2024
@simmsa
Copy link
Contributor

simmsa commented Dec 18, 2024

@MShabara, if this is ready to go can you please add @rpauly18 and myself as reviewers? If not can you convert this to a draft?

@MShabara MShabara assigned MShabara and unassigned MShabara Dec 18, 2024
@MShabara MShabara requested a review from rpauly18 December 18, 2024 17:16
@MShabara MShabara changed the title Adds the uncrossing analysis functions in MATLAB Adds the upcrossing analysis functions in MATLAB Jan 14, 2025
@simmsa simmsa self-requested a review January 14, 2025 16:14
Copy link
Contributor

@simmsa simmsa left a comment

Choose a reason for hiding this comment

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

@MShabara, overall the implementation looks good and I don't see any technical errors. Could you please:

  1. Update the docstrings to follow this projects format
  2. Address the inline comments I've left about test file locations, unused code, and citations

Comment on lines +23 to +33
methods (TestMethodSetup)
% Setup for each test
end

% methods (Test)
% % Test methods
%
% function unimplementedTest(testCase)
% testCase.verifyFail("Unimplemented test");
% end
% end
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this to examples/data/utils ?

---

## Author(s)
- **mshabara**
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +2 to +12
% Apply a function `f` over intervals defined by `inds`. If `inds` is
% not provided, compute the indices using the upcrossing function.

% Input:
% t : Array of time values.
% data : Array of data values.
% f : Function handle that takes two indices (start, end) and returns a scalar value.
% inds : Indices array (optional). If not provided, `upcrossing` will be used.

% Output:
% vals : Array of values resulting from applying `f` over the intervals defined by `inds`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstrings need to follow this projects docstring format, which is used by sphinx-matlabdomain to generate the MHKiT-MATLAB website documentation. For consistency, please reference the format shown in delft_3d_calculate_variable_interpolation.m in the MHKiT-MATLAB repository. This gets rendered here.

At this time I cannot find any specific documentation for this format. I'll update our contributor documentation to include these docstring specifications for future reference.

For this function the docstring should be:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Apply a function over defined intervals in time series data.
%
% Parameters
% ------------
%     t: array
%         Array of time values.
%     data: array
%         Array of data values.
%     f: function handle
%         Function that takes two indices (start, end) and returns a scalar value.
%     inds: array, optional
%         Indices array defining the intervals. If not provided, intervals will be
%         computed using the upcrossing function.
%
% Returns
% ---------
%     vals: array
%         Array of values resulting from applying the function over the defined intervals.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end

n = numel(inds) - 1; % Number of intervals
vals = zeros(1, n); % Initialize the output array
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think the vals array should be initialized as zeros? If f fails to return would that leave unintended zeroes in the output? Maybe it would be better to initialize the output vals array as NaNs?

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.

2 participants