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

Add round trip test for analysis::load_parameters and analysis::save_… #2711

Merged
merged 2 commits into from
Jan 14, 2022

Conversation

ManInFez
Copy link
Contributor

@ManInFez ManInFez commented Jan 13, 2022

…parameters

Issue
Resolves #2581
Resolves #2583

Approach
Performing a roundtrip test where a matrix is first written to a enkf_fs instance and the loaded back

Pre review checklist

  • Added appropriate labels

Adding labels helps the maintainers when writing release notes, see sections and the
corresponding labels here: https://github.com/equinor/ert/blob/main/.github/release.yml

@codecov-commenter
Copy link

codecov-commenter commented Jan 13, 2022

Codecov Report

Merging #2711 (c8a8788) into main (ce70019) will increase coverage by 0.41%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2711      +/-   ##
==========================================
+ Coverage   64.90%   65.32%   +0.41%     
==========================================
  Files         651      651              
  Lines       53687    53655      -32     
  Branches     4733     4724       -9     
==========================================
+ Hits        34846    35050     +204     
+ Misses      17363    17071     -292     
- Partials     1478     1534      +56     
Impacted Files Coverage Δ
libres/lib/analysis/update.cpp 43.60% <ø> (+34.70%) ⬆️
libres/lib/res_util/block_fs.cpp 53.97% <0.00%> (+0.44%) ⬆️
libres/lib/res_util/matrix.cpp 66.21% <0.00%> (+0.90%) ⬆️
libres/lib/enkf/time_map.cpp 54.00% <0.00%> (+0.91%) ⬆️
res/enkf/enkf_fs_manager.py 94.00% <0.00%> (+1.00%) ⬆️
libres/lib/enkf/enkf_fs.cpp 75.12% <0.00%> (+1.49%) ⬆️
libres/lib/enkf/enkf_main_manage_fs.cpp 63.00% <0.00%> (+1.83%) ⬆️
libres/lib/enkf/enkf_node.cpp 52.41% <0.00%> (+2.03%) ⬆️
ert_shared/main.py 86.00% <0.00%> (+3.25%) ⬆️
libres/lib/analysis/enkf_linalg.cpp 45.71% <0.00%> (+4.15%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce70019...c8a8788. Read the comment docs.

@ManInFez ManInFez force-pushed the testing_save_parameters branch 2 times, most recently from ec2356d to 9861f06 Compare January 13, 2022 13:26
@sregales-TNO
Copy link
Contributor

test this please

@ManInFez
Copy link
Contributor Author

Test ert please!

@sregales-TNO
Copy link
Contributor

sregales-TNO commented Jan 13, 2022

I see you have two separate issues for save and load (#2581 and #2583). I see that this test covers load and thus implicitly covers save, but are their assertions that we want to invoke on save (#2581)? because we can do it in this issue. with another WHEN or/and THEN.

SENARIO(""){
WHEN("save"){
THEN(""){
save assersions...
}
}
WHEN("load"){
THEN(""){
load assersions...
}
}
}

@ManInFez
Copy link
Contributor Author

Test ert please!

matrix_type *load_parameters(enkf_fs_type *target_fs,
ensemble_config_type *ensemble_config,
const int_vector_type *iens_active_index,
int last_step, int active_ens_size,
Copy link
Contributor

Choose a reason for hiding this comment

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

The parameter active_ens_size is not required - that equals int_vector_size( iens_active_index );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this does not work when only running a subset of realizations 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

OK I agree;

ens_size = int_vector_size( iens_active_index ) - int_vector_count_equal( iens_active_index, int_vector_get_default( iens_active_index));

@ManInFez
Copy link
Contributor Author

I see you have two separate issues for save and load (#2581 and #2583). I see that this test covers load and thus implicitly covers save, but are their assertions that we want to invoke on save (#2581)? because we can do it in this issue. with another WHEN or/and THEN.

SENARIO(""){
WHEN("save"){
THEN(""){
save assersions...
}
}
WHEN("load"){
THEN(""){
load assersions...
}
}
}

not sure if there are any meaningful assertions to be made after save_parameters which are not covered by load_parameters

@ManInFez ManInFez closed this Jan 14, 2022
@ManInFez ManInFez reopened this Jan 14, 2022
@ManInFez
Copy link
Contributor Author

Test ert please!

}

// Create matrix and save as as the parameter defined in the ministep
matrix_type *A = matrix_alloc(1, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the literal 10 should be named symbol ens_size

void save_parameters(enkf_fs_type *target_fs,
ensemble_config_type *ensemble_config,
const int_vector_type *iens_active_index, int last_step,
const local_ministep_type *ministep, matrix_type *A);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the input-matrix A be defined as const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since it is passed to the serialize_info_alloc wich is also used in load_parameters it can not be const

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something we should consider redesigning as it is a bit hard to parse, for me at least.
I would expect a function called save_parameters to be able to take const matrix_type *A.
Not saying we should do it in this PR!

Copy link
Contributor

@dafeda dafeda left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ManInFez ManInFez merged commit 09152c9 into equinor:main Jan 14, 2022
@ManInFez ManInFez deleted the testing_save_parameters branch January 14, 2022 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants