GEUS-SICE / SICE

Operational Sentinel-3 snow and ice products (SICE) - Geological Survey of Denmark and Greenland (GEUS)
http://snow.geus.dk
GNU General Public License v3.0
5 stars 2 forks source link

./sice_lib.py:424:65: F821 undefined name 'd' #44

Closed AdrienWehrle closed 2 years ago

AdrienWehrle commented 2 years ago

Spotted by flake8 when added to the workflow in 9aff0c52a5b5921df1bc7c5fb4b2473e68e43f27. d is indeed only defined few lines below but is already used in this condition.

The condition can't simply be moved at the end of the method because x1 and x2 are used for it but reassigned few lines below, so I don't think I understand that code. We should really avoid reassignments (here at L434)... @BaptisteVandecrux, could you help? Thanks a lot in advance!

https://github.com/GEUS-SICE/SICE/blob/9aff0c52a5b5921df1bc7c5fb4b2473e68e43f27/sice_lib.py#L422-L428

BaptisteVandecrux commented 2 years ago

On the first iteration of the while loop mflag = True so the test on L426 is always False at first and the d therein is not used. So this should not cause any issue. We could assign a dummy (nan?) value to d before the while loop.

AdrienWehrle commented 2 years ago

Thanks! I just proposed the change in the above PR.