Commit a3d76351 authored by Dóra Kocsis's avatar Dóra Kocsis

add unit test and modify template to include example with filtered series, closes #3

parent 14413931
......@@ -23,9 +23,14 @@ df_cart = fetch_series_by_api_link("https://api.db.nomics.world/v22/series?serie
df_multi_freq = fetch_series('series_ids', ["BEA/NIUnderlyingDetail-U001BC/S315-A",...
"BEA/NIUnderlyingDetail-U001BC/S315-Q",...
"BEA/NIUnderlyingDetail-U001BC/S315-M"]);
%% TO BE IMPLEMENTED
% fetch one series and apply interpolation filter %NOT IMPLEMENTED
% fetch one series and apply interpolation filter
filters_ = '[{"code": "interpolate", "parameters": {"frequency": "monthly", "method": "spline"}}]';
df_filter = fetch_series('series_ids', "AMECO/ZUTN/EA19.1.0.0.0.ZUTN",...
'dbnomics_filters', '[{"code": "interpolate", "parameters": {"frequency": "monthly", "method": "spline"}}]');
'dbnomics_filters', filters_);
% fetch multiple series and apply interpolation filter
df_filters = fetch_series('series_ids', ["AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"],...
'dbnomics_filters', filters_);
\ No newline at end of file
......@@ -11,6 +11,7 @@ r = [r; run_this_test('test_fetch_series_of_dataset')];
r = [r; run_this_test('test_fetch_series_by_api_link')];
r = [r; run_this_test('test_fetch_series_with_na_values')];
r = [r; run_this_test('test_fetch_series_with_max_nb_series')];
r = [r; run_this_test('test_fetch_series_with_filter_on_one_series')];
print_results(r);
......
function test_fetch_series_with_filter_on_one_series()
filters_ = '[{"code": "interpolate", "parameters": {"frequency": "monthly", "method": "spline"}}]';
df = fetch_series('provider_code', "AMECO", 'dataset_code', "ZUTN", 'series_code', "DEU.1.0.0.0.ZUTN", 'dbnomics_filters', filters_);
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(series_codes{1} == "DEU.1.0.0.0.ZUTN");
assert(any(find(strcmp('filtered',df(1,:)))));
idx_freq = find(strcmp('x_frequency',df(1,:)));
frequencies = unique(df(2:end, idx_freq));
assert(any(strcmp(frequencies, "monthly")));
assert(any(contains(series_codes, "_filtered")));
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment