-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
In the test_bin_statistics test (currently disabled) there is a failure caused by comparisons of 0 to NaN. The underlying JSON data has NaN where bins are empty and the bin_statistics function returns zeros:
MHKiT-MATLAB/mhkit/tests/Loads_TestLoads.m
Lines 5 to 29 in 31388bb
| function test_bin_statistics(testCase) | |
| assumeFail(testCase, "Temporarily Disabled - Need to ask @hivanov about nan vs zero comparison") | |
| % create array containg wind speeds to use as bin edges | |
| bin_edges = 3:1:25; | |
| relative_file_name = '../../examples/data/loads/loads_data_dict.json'; | |
| full_file_name = fullfile(fileparts(mfilename('fullpath')), relative_file_name); | |
| fid = fopen(full_file_name); % Opening the file | |
| raw = fread(fid,inf); % Reading the contents | |
| str = char(raw'); % Transformation | |
| fclose(fid); % Closing the file | |
| data = jsondecode(str); % Using the jsondecode function to parse JSON from string | |
| % Apply function to calculate means | |
| load_means_struct = [data.means.uWind_80m]; | |
| load_means_table = struct2table(data.means); | |
| ta = struct2table([data.bin_means]); | |
| st = table2struct(ta,'ToScalar',true); | |
| ta_std = struct2table([data.bin_means_std]); | |
| st_std = table2struct(ta_std,'ToScalar',true); | |
| bin_against = load_means_struct;% load_means_table.uWind_80m; | |
| datast = bin_statistics(load_means_table,bin_against,bin_edges); | |
| assertEqual(testCase,st,datast.averages,'RelTol',0.001) | |
| assertEqual(testCase,st_std,datast.std,'RelTol',0.001) | |
| end |
@hivanov-nrel do you have any suggestions on how to fix? Should empty bins return NaN or 0. Do you think this is a bug in the test or in the bin_statistics function?
Metadata
Metadata
Assignees
Labels
No labels