pytroll / pyresample

Geospatial image resampling in Python
http://pyresample.readthedocs.org
GNU Lesser General Public License v3.0
344 stars 95 forks source link

Add builtin 'config' object and 'features.future_geometry' toggle #519

Closed djhoese closed 1 year ago

djhoese commented 1 year ago

This is the first step of many to allow users a way of transitioning easily between pyresample 1.x and pyresample 2.x interfaces and objects. As a first step this PR adds a new pyresample.config object using donfig and includes a features.future_geometries boolean flag. This flag modifies utility functions like create_area_def to return a future AreaDefinition instead of the old/existing AreaDefinition. Along with some changes to imports users should be able to easily switch usage to the new geometry objects semi-easily (I think).

This also adds a to_legacy() method to the future area so it is easier to create the future area but return the legacy version.

As part of these changes I originally added an import in pyresample/__init__.py so that importing AreaDefinition and SwathDefinition from pyresample would get you the new versions of the classes if this toggle config flag was set. This seemed near impossible to test so I ended up removing it.

TODO:

codecov[bot] commented 1 year ago

Codecov Report

Merging #519 (30305c2) into main (327cec1) will increase coverage by 0.02%. The diff coverage is 95.69%.

@@            Coverage Diff             @@
##             main     #519      +/-   ##
==========================================
+ Coverage   94.31%   94.33%   +0.02%     
==========================================
  Files          79       82       +3     
  Lines       12936    13001      +65     
==========================================
+ Hits        12201    12265      +64     
- Misses        735      736       +1     
Flag Coverage Δ
unittests 94.33% <95.69%> (+0.02%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyresample/test/test_gradient.py 99.00% <ø> (+0.01%) :arrow_up:
pyresample/utils/rasterio.py 62.50% <83.33%> (+8.92%) :arrow_up:
pyresample/test/test_utils.py 99.37% <97.05%> (-0.63%) :arrow_down:
pyresample/_config.py 100.00% <100.00%> (ø)
pyresample/area_config.py 90.58% <100.00%> (+0.13%) :arrow_up:
pyresample/future/geometry/area.py 100.00% <100.00%> (ø)
pyresample/geometry.py 87.50% <100.00%> (+<0.01%) :arrow_up:
pyresample/test/conftest.py 98.46% <100.00%> (+0.06%) :arrow_up:
pyresample/test/test_config/__init__.py 100.00% <100.00%> (ø)
pyresample/test/test_config/test_feature_flags.py 100.00% <100.00%> (ø)
... and 3 more

... and 2 files with indirect coverage changes

coveralls commented 1 year ago

Coverage Status

coverage: 93.941% (+0.1%) from 93.846% when pulling 30305c2d4dc35b1b944769c5142285564290b98d on djhoese:feature-config-feat-flags into 2b94b704365507a3ac9b2de9e9a25e5414792b73 on pytroll:main.

djhoese commented 1 year ago

Everything should be fixed here, but I'll wait to merge until the various bug fix PRs are merged and released.