diff --git a/.gitignore b/.gitignore index 011c691..aa139f1 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ docs/_build docs/api .idea + +# created automatically by setuptools.scm, don't track +version.py diff --git a/.readthedocs.yml b/.readthedocs.yml index 312c80a..6315ed2 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -9,7 +9,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "mambaforge-4.10" + python: "3.10" # Build documentation in the docs/ directory with Sphinx sphinx: @@ -24,9 +24,9 @@ formats: - htmlzip # Optionally set the version of Python and requirements required to build your docs -conda: - environment: docs/environment.yml python: install: - method: pip path: . + extra_requirements: + - docs diff --git a/CITATION.cff b/CITATION.cff index 954654e..7652ecc 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -17,9 +17,8 @@ authors: given-names: Nikhil - family-names: Ward given-names: Brian -orcid: https://orcid.org/0000-0000-0000-0000 title: "Pyrtools: tools for multi-scale image processing" -version: v1.0.3 +version: v1.0.4 date-released: 2023-11-20 doi: 10.5281/zenodo.10161031 url: "https://github.com/LabForComputationalVision/pyrtools" diff --git a/README.md b/README.md index 0713085..523d236 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Build Status](https://github.com/LabForComputationalVision/pyrtools/workflows/build/badge.svg)](https://github.com/LabForComputationalVision/pyrtools/actions?query=workflow%3Abuild) [![Documentation Status](https://readthedocs.org/projects/pyrtools/badge/?version=latest)](https://pyrtools.readthedocs.io/en/latest/?badge=latest) [![DOI](https://zenodo.org/badge/137527035.svg)](https://zenodo.org/doi/10.5281/zenodo.10161031) -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.3?filepath=TUTORIALS%2F) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.4?filepath=TUTORIALS%2F) [![codecov](https://codecov.io/gh/LabForComputationalVision/pyrtools/branch/main/graph/badge.svg?token=Ei9TYftdYi)](https://codecov.io/gh/LabForComputationalVision/pyrtools) Briefly, the tools include: @@ -20,10 +20,11 @@ Briefly, the tools include: auto-scaling options, rounding to integer zoom factors to avoid resampling artifacts, and useful labeling (dimensions and gray-range). -This is a python 3 port of Eero Simoncelli's matlabPyrTools, but it -does not attempt to recreate all of the matlab code from -matlabPyrTools. The goal is to create a Python interface for the C -code at the heart of matlabPyrTools. +This is a python 3 port of Eero Simoncelli's +[matlabPyrTools](https://github.com/LabForComputationalVision/matlabPyrTools), +but it does not attempt to recreate all of the matlab code from matlabPyrTools. +The goal is to create a Python interface for the C code at the heart of +matlabPyrTools. **NOTE**: If you are only interested in the complex steerable pyramid, we have a pytorch implementation in the @@ -49,19 +50,6 @@ want the changes you make in the directory to be reflected in your install) from the root directory of this project. The core of this code is the C code, and the pip install will compile it nicely. -## Dependencies - -Dependencies are documented in `setup.py`. - -IPython is optional. If it's not installed, -`pyrtools.display_tools.animshow` must be called with `as_html5=False` -(but since this is for displaying the animated image in a Jupyter / -IPython notebook, you probably won't need that functionality). - -For the C code to compile, we require `gcc` version >= 6, because of -[this -issue](https://stackoverflow.com/questions/46504700/gcc-compiler-not-recognizing-fno-plt-option) - # Pyramid resources If you would like to learn more about pyramids and why they're helpful @@ -78,23 +66,9 @@ for image processing, here are some resources to get you started: - Notes from Eero Simoncelli on [the Steerable Pyramid](http://www.cns.nyu.edu/~eero/STEERPYR/) -# Authors - -Rob Young and Eero Simoncelli, 7/13 - -William Broderick, 6/17 - -William Broderick, Pierre-Étienne Fiquet, Zhuo Wang, Zahra Kadkhodaie, -Nikhil Parthasarathy, and the Lab for Computational Vision, 4/19 - # Usage: -method parameters mimic the matlab function parameters except that there's no -need to pass pyr or pind, since the pyPyrTools version pyr and pyrSize are -properties of the class. - -- load modules (note that if you installed via pip, you can skip the - first two lines): +- load modules: ``` import pyrtools as pt ``` @@ -109,22 +83,16 @@ pyr = pt.pyramids.LaplacianPyramid(img) recon_img = pyr.recon_pyr() ``` -Please see `TUTORIALS/02_pyramids.ipynb` for more examples. You can -start this with: `jupyter notebook 02_pyramids.ipynb` if you have iPython -and Jupyter installed. +Please see `TUTORIALS/02_pyramids.ipynb` for more examples. -# Testing +# For developres -All code should be considered a beta release. By that we mean that it is being -actively developed and tested. You can find unit tests in -`TESTS/unitTests.py` and run them with `python TESTS/unitTests.py`. +## Testing -If you're using functions or parameters that do not have associated unit -tests you should test this yourself to make sure the results are correct. -You could then submit your test code, so that we can build more complete -unit tests. +You can find unit tests in `TESTS/unitTests.py` and run them with `python +TESTS/unitTests.py`. -# Build the documentation +## Build the documentation NOTE: If you just want to read the documentation, you do not need to do this; documentation is built automatically on @@ -132,18 +100,12 @@ do this; documentation is built automatically on However, it can be built locally as well. You would do this if you've made changes locally to the documentation (or the docstrings) that you -would like to examine before pushing. The virtual environment required -to do so is defined in `docs/environment.yml`, so to create that -environment and build the docs, do the following from the project's -root directory: +would like to examine before pushing. ``` -# install sphinx and required packages to build documentation -conda env create -f docs/environment.yml -# activate the environment -conda activate pyrtools_docs -# install pyrtools -pip install -e . +# create a new virtual environment and then... +# install pyrtools with sphinx and documentation-related dependencies +pip install -e .[docs] # build documentation cd docs/ make html @@ -152,10 +114,3 @@ make html The index page of the documentation will then be located at `docs/_build/html/index.html`, open it in your browser to navigate around. - -The `pyrtools_docs` environment you're creating contains the package -`sphinx` and several extensions for it that are required to build the -documentation. You also need to install `pyrtools` from your local -version so that `sphinx` can import the library and grab all of the -docstrings (you're installing the local version so you can see all the -changes you've made). diff --git a/docs/environment.yml b/docs/environment.yml deleted file mode 100644 index 85d6208..0000000 --- a/docs/environment.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: pyrtools_docs - -channels: - - conda-forge - -dependencies: - - sphinx - - numpydoc - - numpy - - python - - pip - - ipython - - pip: - - nbsphinx - - nbsphinx_link - - sphinxcontrib-apidoc - # fix sphinx 7 incompatibility issue - - 'sphinx_rtd_theme>=1.3.0rc1' diff --git a/docs/index.rst b/docs/index.rst index d49cde0..35749fd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,7 +10,7 @@ :target: https://github.com/LabForComputationalVision/pyrtools/actions?query=workflow%3Abuild .. |binder| image:: https://mybinder.org/badge_logo.svg - :target: https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.3?filepath=TUTORIALS%2F + :target: https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.4?filepath=TUTORIALS%2F .. |doi| image:: https://zenodo.org/badge/137527035.svg :target: https://zenodo.org/doi/10.5281/zenodo.10161031 diff --git a/docs/installation.rst b/docs/installation.rst index 4aae2ed..d3d63b9 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -37,4 +37,4 @@ When installing from source on Linux or Mac, we require ``gcc`` version >= 6 in order for the C code to compile, because of `this issue `_ -When installing from source on Windows, Microsoft Visual C++ 14.0 or greater is required, which can be obtained with `Microsoft C++ Build Tools `_. diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 2c6dfd1..5ca3944 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -11,14 +11,6 @@ In the python interpreter, then call:: import pyrtools as pt -which should run without errors if the install worked correctly. If -you have an issue with the installation, it will most likely be with -the compilation of the C code. There is hopefully a warning of this -when you import the library, but if you get an error message along the -lines of `lib not defined` when attempting to build a pyramid or call -the functions `corrDn`, `upConv`, or `pointOp`, this is probably -what's at fault. - Create pyramid:: pyr = pt.pyramids.LaplacianPyramid(img) @@ -28,7 +20,7 @@ Reconstruct image from pyramid:: recon_img = pyr.recon_pyr() For more details, see the jupyter notebooks included in the -`TUTORIALS/` directory, static versions of which are linked in the +``TUTORIALS/`` directory, static versions of which are linked in the navigation sidebar. You can play around with a live version of them in order to test out the code before downloading on `binder -`_ +`_ diff --git a/pyproject.toml b/pyproject.toml index 9787c3b..a1da994 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,51 @@ +[project] +name = "pyrtools" +dynamic = ["version"] +authors = [{name="Pyrtools authors"}] +description = "Python tools for multi-scale image processing, including Laplacian pyramids, Wavelets, and Steerable Pyramids." +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Science/Research", +] +keywords = ['image processing', 'visual information processing', 'computational models'] + +dependencies = ['numpy>=1.1', + 'scipy>=0.18', + 'matplotlib>=1.5', + 'tqdm>=4.29', + 'requests>=2.21'] + +[project.optional-dependencies] +docs = [ + 'sphinx', + 'numpydoc', + # because of this issue: + # https://nbsphinx.readthedocs.io/en/0.6.0/installation.html#Pygments-Lexer-for-Syntax-Highlighting + 'ipython', + 'nbsphinx', + 'nbsphinx_link', + 'sphinxcontrib-apidoc', + # fix sphinx 7 incompatibility issue + 'sphinx_rtd_theme>=1.3.0rc1' +] + [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools", "wheel", "setuptools-scm[toml]"] build-backend = "setuptools.build_meta" + +[project.urls] +"Homepage" = "https://github.com/LabForComputationalVision/pyrtools" +"Documentation" = "https://pyrtools.readthedocs.io/en/latest/" +"Download" = "https://zenodo.org/records/10403034" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools_scm] +write_to = "src/pyrtools/version.py" +version_scheme = 'python-simplified-semver' +local_scheme = 'no-local-version' diff --git a/pyrtools/version.py b/pyrtools/version.py deleted file mode 100644 index 001c4cb..0000000 --- a/pyrtools/version.py +++ /dev/null @@ -1 +0,0 @@ -version = '1.0.3' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 224a779..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py index 48783ce..34545e0 100644 --- a/setup.py +++ b/setup.py @@ -2,15 +2,6 @@ from wheel.bdist_wheel import bdist_wheel from setuptools import setup, Extension -import importlib -import os - -# copied from kymatio's setup.py: https://github.com/kymatio/kymatio/blob/master/setup.py -pyrtools_version_spec = importlib.util.spec_from_file_location('pyrtools_version', - 'pyrtools/version.py') -pyrtools_version_module = importlib.util.module_from_spec(pyrtools_version_spec) -pyrtools_version_spec.loader.exec_module(pyrtools_version_module) -VERSION = pyrtools_version_module.version # Adapted from the cibuildwheel example https://github.com/joerick/python-ctypes-package-sample # it marks the wheel as not specific to the Python API version. @@ -25,33 +16,15 @@ def get_tag(self): setup( - name='pyrtools', - version=VERSION, - long_description=open('README.md', 'r').read(), - long_description_content_type='text/markdown', - description='Python tools for multi-scale image processing, including Laplacian pyramids, Wavelets, and Steerable Pyramids', - license='MIT', - url='https://github.com/LabForComputationalVision/pyrtools', - author='Eero Simoncelli', - author_email='eero.simoncelli@nyu.edu', - keywords='multi-scale image-processing', - packages=['pyrtools', 'pyrtools.pyramids', 'pyrtools.tools', 'pyrtools.pyramids.c'], - package_data={'': ['*.h', 'LICENSE']}, - install_requires=['numpy>=1.1', - 'scipy>=0.18', - 'matplotlib>=1.5', - 'tqdm>=4.29', - 'requests>=2.21'], ext_modules=[Extension('pyrtools.pyramids.c.wrapConv', - sources=['pyrtools/pyramids/c/py.c', - 'pyrtools/pyramids/c/convolve.c', - 'pyrtools/pyramids/c/edges.c', - 'pyrtools/pyramids/c/wrap.c', - 'pyrtools/pyramids/c/internal_pointOp.c'], - depends=['pyrtools/pyramids/c/meta.h', - 'pyrtools/pyramids/c/convolve.h', - 'pyrtools/pyramids/c/internal_pointOp.h'], + sources=['src/pyrtools/pyramids/c/py.c', + 'src/pyrtools/pyramids/c/convolve.c', + 'src/pyrtools/pyramids/c/edges.c', + 'src/pyrtools/pyramids/c/wrap.c', + 'src/pyrtools/pyramids/c/internal_pointOp.c'], + depends=['src/pyrtools/pyramids/c/meta.h', + 'src/pyrtools/pyramids/c/convolve.h', + 'src/pyrtools/pyramids/c/internal_pointOp.h'], extra_compile_args=['-fPIC', '-shared'])], cmdclass={"bdist_wheel": WheelABINone}, - tests='TESTS', ) diff --git a/pyrtools/__init__.py b/src/pyrtools/__init__.py similarity index 100% rename from pyrtools/__init__.py rename to src/pyrtools/__init__.py diff --git a/pyrtools/pyramids/GaussianPyramid.py b/src/pyrtools/pyramids/GaussianPyramid.py similarity index 100% rename from pyrtools/pyramids/GaussianPyramid.py rename to src/pyrtools/pyramids/GaussianPyramid.py diff --git a/pyrtools/pyramids/LaplacianPyramid.py b/src/pyrtools/pyramids/LaplacianPyramid.py similarity index 100% rename from pyrtools/pyramids/LaplacianPyramid.py rename to src/pyrtools/pyramids/LaplacianPyramid.py diff --git a/pyrtools/pyramids/SteerablePyramidFreq.py b/src/pyrtools/pyramids/SteerablePyramidFreq.py similarity index 100% rename from pyrtools/pyramids/SteerablePyramidFreq.py rename to src/pyrtools/pyramids/SteerablePyramidFreq.py diff --git a/pyrtools/pyramids/SteerablePyramidSpace.py b/src/pyrtools/pyramids/SteerablePyramidSpace.py similarity index 100% rename from pyrtools/pyramids/SteerablePyramidSpace.py rename to src/pyrtools/pyramids/SteerablePyramidSpace.py diff --git a/pyrtools/pyramids/WaveletPyramid.py b/src/pyrtools/pyramids/WaveletPyramid.py similarity index 100% rename from pyrtools/pyramids/WaveletPyramid.py rename to src/pyrtools/pyramids/WaveletPyramid.py diff --git a/pyrtools/pyramids/__init__.py b/src/pyrtools/pyramids/__init__.py similarity index 100% rename from pyrtools/pyramids/__init__.py rename to src/pyrtools/pyramids/__init__.py diff --git a/pyrtools/pyramids/c/__init__.py b/src/pyrtools/pyramids/c/__init__.py similarity index 100% rename from pyrtools/pyramids/c/__init__.py rename to src/pyrtools/pyramids/c/__init__.py diff --git a/pyrtools/pyramids/c/convolve.c b/src/pyrtools/pyramids/c/convolve.c similarity index 100% rename from pyrtools/pyramids/c/convolve.c rename to src/pyrtools/pyramids/c/convolve.c diff --git a/pyrtools/pyramids/c/convolve.h b/src/pyrtools/pyramids/c/convolve.h similarity index 100% rename from pyrtools/pyramids/c/convolve.h rename to src/pyrtools/pyramids/c/convolve.h diff --git a/pyrtools/pyramids/c/edges.c b/src/pyrtools/pyramids/c/edges.c similarity index 100% rename from pyrtools/pyramids/c/edges.c rename to src/pyrtools/pyramids/c/edges.c diff --git a/pyrtools/pyramids/c/internal_pointOp.c b/src/pyrtools/pyramids/c/internal_pointOp.c similarity index 100% rename from pyrtools/pyramids/c/internal_pointOp.c rename to src/pyrtools/pyramids/c/internal_pointOp.c diff --git a/pyrtools/pyramids/c/internal_pointOp.h b/src/pyrtools/pyramids/c/internal_pointOp.h similarity index 100% rename from pyrtools/pyramids/c/internal_pointOp.h rename to src/pyrtools/pyramids/c/internal_pointOp.h diff --git a/pyrtools/pyramids/c/meta.h b/src/pyrtools/pyramids/c/meta.h similarity index 100% rename from pyrtools/pyramids/c/meta.h rename to src/pyrtools/pyramids/c/meta.h diff --git a/pyrtools/pyramids/c/py.c b/src/pyrtools/pyramids/c/py.c similarity index 100% rename from pyrtools/pyramids/c/py.c rename to src/pyrtools/pyramids/c/py.c diff --git a/pyrtools/pyramids/c/wrap.c b/src/pyrtools/pyramids/c/wrap.c similarity index 100% rename from pyrtools/pyramids/c/wrap.c rename to src/pyrtools/pyramids/c/wrap.c diff --git a/pyrtools/pyramids/c/wrapper.py b/src/pyrtools/pyramids/c/wrapper.py similarity index 100% rename from pyrtools/pyramids/c/wrapper.py rename to src/pyrtools/pyramids/c/wrapper.py diff --git a/pyrtools/pyramids/filters.py b/src/pyrtools/pyramids/filters.py similarity index 100% rename from pyrtools/pyramids/filters.py rename to src/pyrtools/pyramids/filters.py diff --git a/pyrtools/pyramids/pyr_utils.py b/src/pyrtools/pyramids/pyr_utils.py similarity index 100% rename from pyrtools/pyramids/pyr_utils.py rename to src/pyrtools/pyramids/pyr_utils.py diff --git a/pyrtools/pyramids/pyramid.py b/src/pyrtools/pyramids/pyramid.py similarity index 100% rename from pyrtools/pyramids/pyramid.py rename to src/pyrtools/pyramids/pyramid.py diff --git a/pyrtools/pyramids/steer.py b/src/pyrtools/pyramids/steer.py similarity index 100% rename from pyrtools/pyramids/steer.py rename to src/pyrtools/pyramids/steer.py diff --git a/pyrtools/tools/__init__.py b/src/pyrtools/tools/__init__.py similarity index 100% rename from pyrtools/tools/__init__.py rename to src/pyrtools/tools/__init__.py diff --git a/pyrtools/tools/compare_matpyrtools.py b/src/pyrtools/tools/compare_matpyrtools.py similarity index 100% rename from pyrtools/tools/compare_matpyrtools.py rename to src/pyrtools/tools/compare_matpyrtools.py diff --git a/pyrtools/tools/convolutions.py b/src/pyrtools/tools/convolutions.py similarity index 100% rename from pyrtools/tools/convolutions.py rename to src/pyrtools/tools/convolutions.py diff --git a/pyrtools/tools/display.py b/src/pyrtools/tools/display.py similarity index 100% rename from pyrtools/tools/display.py rename to src/pyrtools/tools/display.py diff --git a/pyrtools/tools/image_stats.py b/src/pyrtools/tools/image_stats.py similarity index 100% rename from pyrtools/tools/image_stats.py rename to src/pyrtools/tools/image_stats.py diff --git a/pyrtools/tools/synthetic_images.py b/src/pyrtools/tools/synthetic_images.py similarity index 100% rename from pyrtools/tools/synthetic_images.py rename to src/pyrtools/tools/synthetic_images.py diff --git a/pyrtools/tools/utils.py b/src/pyrtools/tools/utils.py similarity index 100% rename from pyrtools/tools/utils.py rename to src/pyrtools/tools/utils.py