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 more tests to check c calls #980

Merged
merged 3 commits into from
May 29, 2024

Conversation

eivindjahren
Copy link
Collaborator

@eivindjahren eivindjahren commented May 28, 2024

Also fixes a bug in Grid.compare.

In order to be able to remove the c code safely, we have to ensure all ReadataPrototypes can still be called. This PR creates tests that tries to call as many of those as possible.

The list of covered resdataprotypes are as follows.

  • python/resdata/__init__.py (no ResdataPrototypes)
  • python/resdata/bin.py (no ResdataPrototypes)
  • python/resdata/geometry/__init__.py (no ResdataPrototypes)
  • python/resdata/geometry/cpolyline.py
  • python/resdata/geometry/cpolyline_collection.py
  • python/resdata/geometry/geo_pointset.py
  • python/resdata/geometry/geo_region.py
  • python/resdata/geometry/geometry_tools.py (no ResdataPrototypes)
  • python/resdata/geometry/polyline.py (no ResdataPrototypes)
  • python/resdata/geometry/surface.py
  • python/resdata/geometry/xyz_io.py (no ResdataPrototypes)
  • python/resdata/gravimetry/__init__.py (no ResdataPrototypes)
  • python/resdata/gravimetry/rd_grav.py
  • python/resdata/gravimetry/rd_subsidence.py
  • python/resdata/grid/__init__.py (no ResdataPrototypes)
  • python/resdata/grid/cell.py (no ResdataPrototypes)
  • python/resdata/grid/faults/__init__.py (no ResdataPrototypes)
  • python/resdata/grid/faults/fault.py (no ResdataPrototypes)
  • python/resdata/grid/faults/fault_block.py
  • python/resdata/grid/faults/fault_block_layer.py
  • python/resdata/grid/faults/fault_collection.py (no ResdataPrototypes)
  • python/resdata/grid/faults/fault_line.py (no ResdataPrototypes)
  • python/resdata/grid/faults/fault_segments.py (no ResdataPrototypes)
  • python/resdata/grid/faults/layer.py
  • python/resdata/grid/rd_grid.py (relying on equinor tests for lgr)
  • python/resdata/grid/rd_grid_generator.py
  • python/resdata/grid/rd_region.py(no ResdataPrototypes)
  • python/resdata/rd_type.py
  • python/resdata/rd_util.py
  • python/resdata/resfile/__init__.py (no ResdataPrototypes)
  • python/resdata/resfile/fortio.py
  • python/resdata/resfile/rd_3d_file.py (no ResdataPrototypes)
  • python/resdata/resfile/rd_3dkw.py (no ResdataPrototypes)
  • python/resdata/resfile/rd_file.py
  • python/resdata/resfile/rd_file_view.py
  • python/resdata/resfile/rd_init_file.py (no ResdataPrototypes)
  • python/resdata/resfile/rd_kw.py
  • python/resdata/resfile/rd_restart_file.py
  • python/resdata/rft/__init__.py (no ResdataPrototypes)
  • python/resdata/rft/rd_rft.py (partially tested through equinor data and difficult to produce data)
  • python/resdata/rft/rd_rft_cell.py (partially tested through equinor data and difficult to produce data)
  • python/resdata/rft/well_trajectory.py (no ResdataPrototypes)
  • python/resdata/summary/__init__.py (no ResdataPrototypes)
  • python/resdata/summary/rd_cmp.py (no ResdataPrototypes)
  • python/resdata/summary/rd_npv.py (no ResdataPrototypes)
  • python/resdata/summary/rd_smspec_node.py
  • python/resdata/summary/rd_sum.py
  • python/resdata/summary/rd_sum_keyword_vector.py
  • python/resdata/summary/rd_sum_node.py (no ResdataPrototypes)
  • python/resdata/summary/rd_sum_tstep.py
  • python/resdata/summary/rd_sum_var_type.py (no ResdataPrototypes)
  • python/resdata/summary/rd_sum_vector.py (no ResdataPrototypes)
  • python/resdata/util/__init__.py (no ResdataPrototypes)
  • python/resdata/util/enums/__init__.py (no ResdataPrototypes)
  • python/resdata/util/enums/rng_alg_type_enum.py (no ResdataPrototypes)
  • python/resdata/util/enums/rng_init_mode_enum.py (no ResdataPrototypes)
  • python/resdata/util/test/__init__.py (no ResdataPrototypes)
  • python/resdata/util/test/debug_msg.py (no ResdataPrototypes)
  • python/resdata/util/test/extended_testcase.py (no ResdataPrototypes)
  • python/resdata/util/test/import_test_case.py (no ResdataPrototypes)
  • python/resdata/util/test/lint_test_case.py (no ResdataPrototypes)
  • python/resdata/util/test/mock/__init__.py (no ResdataPrototypes)
  • python/resdata/util/test/mock/rd_sum_mock.py (no ResdataPrototypes)
  • python/resdata/util/test/path_context.py (no ResdataPrototypes)
  • python/resdata/util/test/resdata_test_runner.py(no ResdataPrototypes)
  • python/resdata/util/test/source_enumerator.py (no ResdataPrototypes)
  • python/resdata/util/test/test_area.py
  • python/resdata/util/test/test_run.py (no ResdataPrototypes)
  • python/resdata/util/util/__init__.py (no ResdataPrototypes)
  • python/resdata/util/util/bool_vector.py
  • python/resdata/util/util/cthread_pool.py (current plan is to remove it)
  • python/resdata/util/util/ctime.py
  • python/resdata/util/util/cwd_context.py (no ResdataPrototypes)
  • python/resdata/util/util/double_vector.py (through vector_template.py)
  • python/resdata/util/util/hash.py
  • python/resdata/util/util/install_abort_signals.py
  • python/resdata/util/util/int_vector.py (through vector_template.py)
  • python/resdata/util/util/lookup_table.py
  • python/resdata/util/util/permutation_vector.py
  • python/resdata/util/util/rng.py
  • python/resdata/util/util/stringlist.py
  • python/resdata/util/util/thread_pool.py (no ResdataPrototypes)
  • python/resdata/util/util/time_vector.py (through vector_template.py)
  • python/resdata/util/util/vector_template.py
  • python/resdata/util/util/version.py
  • python/resdata/version.py (no ResdataPrototypes)
  • python/resdata/well/__init__.py (no ResdataPrototypes)
  • python/resdata/well/well_connection.py
  • python/resdata/well/well_connection_direction_enum.py (no ResdataPrototypes)
  • python/resdata/well/well_info.py
  • python/resdata/well/well_segment.py (only through equinor data)
  • python/resdata/well/well_state.py (self._segment_collection_iget is called with equinor data)
  • python/resdata/well/well_time_line.py
  • python/resdata/well/well_type_enum.py (no ResdataPrototypes)

Of special mention is the vector classes which are tested quite a bit, but the c code is also generated from a template, so although all are not strictly covered, it is not that important.

The few remaining untested ResdataPrototypes are a bit tricky to get to, and it is perhaps not worth it to spend time on it when there is some coverage of it through the equinor testdata.

@eivindjahren eivindjahren force-pushed the add_more_tests_of_prototypes branch 3 times, most recently from ed9be14 to 5d5cc5e Compare May 29, 2024 09:48
The error given is "ffi_prep_cif_var failed" due to
mismatch in arguments.
@eivindjahren eivindjahren force-pushed the add_more_tests_of_prototypes branch from 5d5cc5e to c622f98 Compare May 29, 2024 09:59
@eivindjahren eivindjahren requested a review from berland May 29, 2024 10:04
@eivindjahren eivindjahren self-assigned this May 29, 2024

# The init file created here only contains a PORO field. More
# properties must be added to this before it can be used for
# any usefull gravity calculations.
Copy link
Contributor

Choose a reason for hiding this comment

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

usefull -> useful

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

assert ResdataUtil.get_num_cpu(str(data_file)) == 4


def test_num_cpu_from_data_file_used_if_config_num_cpu_not_set(tmp_path):
Copy link
Contributor

@berland berland May 29, 2024

Choose a reason for hiding this comment

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

This test name seems incorrect

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@eivindjahren eivindjahren force-pushed the add_more_tests_of_prototypes branch from c622f98 to d5f660f Compare May 29, 2024 10:13
@eivindjahren eivindjahren requested a review from berland May 29, 2024 10:32
DIMENS
10 10 10 /
OIL
UNIFOUT
Copy link
Contributor

Choose a reason for hiding this comment

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

No syntax erorr, but I would not separate the line with OIL and the line with WATER with UNIFOUT. Humans need to view line 7 and 9 together to figure out which phase configuration is active.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

/
SOLUTION
EQUIL
3*1000 0 1000 0 0 0 0 /
Copy link
Contributor

Choose a reason for hiding this comment

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

High pressure at shallow depths :)

If it does not matter for values in the test you can have
1000 100 1000 /
instead here to have something slightly more meaningful (item 5 is not relevant in this oil-water problem)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I changed it to what you wanted now.

@eivindjahren eivindjahren force-pushed the add_more_tests_of_prototypes branch from 35c8cb5 to 22880ee Compare May 29, 2024 10:56
Copy link
Contributor

@berland berland left a comment

Choose a reason for hiding this comment

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

Nice!

@eivindjahren eivindjahren merged commit aa0b1ab into equinor:main May 29, 2024
18 checks passed
@eivindjahren eivindjahren deleted the add_more_tests_of_prototypes branch May 29, 2024 11:04
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