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

Move bilinear import to avoid unnecessary warning #400

Merged
merged 1 commit into from
Dec 8, 2021

Conversation

yunjunz
Copy link
Contributor

@yunjunz yunjunz commented Nov 29, 2021

This PR moves the bilinear module import from the top of image.py to the function body of ImageContainerBilinear.resample().

conda install -c conda-forge pyresample does not install xarray and zarr. Thus, if one did not install xarray and zarr manually, running import pyresample will print out the following warning message:

(test) yunjunz:~>$ python -c "import pyresample"
/Users/yunjunz/tools/miniconda3/envs/test/lib/python3.10/site-packages/pyresample/bilinear/__init__.py:50: UserWarning: XArray and/or zarr not found, XArrayBilinearResampler won't be available.
  warnings.warn("XArray and/or zarr not found, XArrayBilinearResampler won't be available.")

With this change, the top-level import pyresample, which calls from pyresample import image, won't call the bilinear module, thus, avoid the warning msg.

to avoid the potential warning msg while import the top level pyresample module. This is because pyresample/__init__.py calls image.py, which import bilinear.py currently. And the later requires xarray/zarr, otherwise print out warning msg.
@djhoese djhoese requested a review from pnuu November 29, 2021 21:50
@codecov
Copy link

codecov bot commented Nov 29, 2021

Codecov Report

Merging #400 (1adca63) into main (e6a452e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #400   +/-   ##
=======================================
  Coverage   93.81%   93.81%           
=======================================
  Files          65       65           
  Lines       11076    11077    +1     
=======================================
+ Hits        10391    10392    +1     
  Misses        685      685           
Flag Coverage Δ
unittests 93.81% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
pyresample/image.py 85.00% <100.00%> (+0.18%) ⬆️

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 e6a452e...1adca63. Read the comment docs.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0006%) to 93.62% when pulling 1adca63 on yunjunz:main into e6a452e on pytroll:main.

@djhoese djhoese added the bug label Dec 8, 2021
@djhoese djhoese changed the title image: move bilinear import from the top to the func body Move bilinear import to avoid unnecessary warning Dec 8, 2021
@djhoese djhoese merged commit 14a17c1 into pytroll:main Dec 8, 2021
@djhoese
Copy link
Member

djhoese commented Dec 8, 2021

Looks good. Thank you very much for clearing this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing pyresample without having Xarray and/or zarray raises UserWarning
3 participants