equinor / xtgeo

XTGeo Python class library for subsurface Surfaces, Cubes, Wells, Grids, Points, etc
https://xtgeo.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
109 stars 56 forks source link

CLN: Map fileformats to internal enum #1134

Closed mferrera closed 6 months ago

mferrera commented 6 months ago

Resolves #1129

Getting the fileformat was reduced to one method call, fmt = pfile.fileformat(fformat) over the previous detection and proposal methods. It does basically the same thing but rolled into a single method. I want to remove this later, however, and do something like:

gfile = FileWrapper(egridfile, format=fformat)
# fformat = gfile.fileformat(fformat) -- this is no longer needed!
assert gfile.format == FileFormat.EGRID  # True

This requires a bit more refactoring though for when a FileWrapper is made for exporting; too much for this PR, #1135

codecov-commenter commented 6 months ago

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (dea0e45) 80.11% compared to head (dfa57a7) 80.27%.

Files Patch % Lines
src/xtgeo/grid3d/grid_property.py 73.68% 4 Missing and 1 partial :warning:
src/xtgeo/surface/regular_surface.py 83.87% 4 Missing and 1 partial :warning:
src/xtgeo/io/__init__.py 0.00% 3 Missing :warning:
src/xtgeo/grid3d/_gridprop_import_eclrun.py 60.00% 1 Missing and 1 partial :warning:
src/xtgeo/well/_well_aux.py 71.42% 1 Missing and 1 partial :warning:
src/xtgeo/grid3d/_grdecl_grid.py 87.50% 0 Missing and 1 partial :warning:
src/xtgeo/grid3d/_grid3d_utils.py 0.00% 1 Missing :warning:
src/xtgeo/grid3d/_grid_export.py 0.00% 1 Missing :warning:
src/xtgeo/grid3d/_grid_import.py 90.00% 0 Missing and 1 partial :warning:
src/xtgeo/grid3d/_grid_import_roff.py 0.00% 1 Missing :warning:
... and 9 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1134 +/- ## ========================================== + Coverage 80.11% 80.27% +0.15% ========================================== Files 98 99 +1 Lines 13609 13589 -20 Branches 2197 2178 -19 ========================================== + Hits 10903 10908 +5 + Misses 1970 1957 -13 + Partials 736 724 -12 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mferrera commented 6 months ago

@jcrivenaes my thought was to indicate that these are private to users for now since they are liable to change quite a lot as things are moved into xtgeo.io. I think it's extremely unlikely that anyone will use them -- but at least our bases would be covered by convention if they do.

I made an exception for typing purposes, though! xtgeo.io.FileFormat/FileWrapper is available only under a TYPE_CHECKING guard, just as a small convenience.

With the added context, what do you think? I'm happy to move them public but I think it could be preferred to mark them private for now.