nasa-jpl / autoRIFT

A Python module of a fast and intelligent algorithm for finding the pixel displacement between two images
Apache License 2.0
212 stars 52 forks source link

Deprecated numpy functions #97

Open adehecq opened 3 months ago

adehecq commented 3 months ago

Since version 1.24, numpy has deprecated the aliases np.bool and np.int, which are still used at numerous occasions in autorift, leaving the user with an AttributeError. It can be easily fixed by replacing all occurrence of np.bool with bool and np.int with int.

Also np.asscalar has also been removed in version 1.23. I think it can be safely replaced by calling int() instead.

jhkennedy commented 3 months ago

@adehecq this was largely done in #88, but some of the un-distributed scripts were missed, and I don't think np.assscalar was checked for either.

If you have time, I'll happily review a PR, merge, and cut a new release. Otherwise, it will take me a bit to get to this.

adehecq commented 3 months ago

Hi @jhkennedy,

yes, I was thinking about submitting a PR, but I was working on the conda install directly, not on a clone of the repository. I tried cloning the repository and running python setup.py install as recommended in the installation notes but I get the following error: "geo_autoRIFT/autoRIFT/bindings/autoriftcoremodule.cpp:43:10: fatal error: opencv2/imgproc/imgproc.hpp: No such file or directory" (also the setup.py raises a DeprecationWarning). Note that I'm installing directly in the conda environment that I created for installing autorift in the first place, and that already installed all dependencies, as I could not find an environment file in this repository. Could you please indicate the way to go forward? Thanks!

scottyhq commented 3 months ago

@adehecq @jhkennedy looks like setup.py is assuming a linux machine with paths to library files that don't necessarily match opencv installed from conda. We were recently working around this by adding a path to the hpp files under the conda environment directory, see https://github.com/nasa-jpl/autoRIFT/compare/master...relativeorbit:autoRIFT:condaInstall.

The PR above fixes the lingering np.asscalars . Would be great to have a release on pypi (and conda-forge) to simplify installing and compatible with numpy>1.23 (and soon-to-be-released numpy2)

jhkennedy commented 3 months ago

@adehecq to install into an existing conda environment, I think you can do:

python -m pip install --global-option=build_ext --global-option="-I${CONDA_PREFIX}/include/opencv4" .

based on the conda-forge recipe: https://github.com/conda-forge/autorift-feedstock/blob/main/recipe/meta.yaml#L18

@scottyhq I agree we should add an environment.yml file, and I'd be happy to review a PR for that.

Really, the entire build and packaging system needs to be reworked, and quite a bit of geogrid/autorift could be refactored for usability. I'm planning later this summer or maybe early fall to start in on that.