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

Make noisyopt an optional dependency #397

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ dependencies:
# - richdem

- pip:
- noisyopt
- scikit-gstat>=1.0.11
- -e ./

# Development-specific
- noisyopt

# - git+https://github.com/GlacioHack/GeoUtils.git
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- pip

- pip:
- noisyopt
- scikit-gstat>=1.0.11


Expand Down
11 changes: 10 additions & 1 deletion xdem/coreg/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import scipy.ndimage
import scipy.optimize
from geoutils.raster import RasterType, get_array_and_mask
from noisyopt import minimizeCompass
from tqdm import trange

from xdem._typing import NDArrayf
Expand All @@ -41,6 +40,13 @@
except ImportError:
_HAS_P3D = False

try:
from noisyopt import minimizeCompass

_has_noisyopt = True
except ImportError:
_has_noisyopt = False

######################################
# Generic functions for affine methods
######################################
Expand Down Expand Up @@ -950,6 +956,9 @@ def _fit_pts_func(

"""

if not _has_noisyopt:
raise ValueError("Optional dependency needed. Install 'noisyopt'")

# downsampling if downsampling != None
if self.downsampling and len(ref_dem) > self.downsampling:
ref_dem = ref_dem.sample(frac=self.downsampling / len(ref_dem), random_state=42).copy()
Expand Down
Loading