From 442fa2c71f61eb7e4b65254a194ccf509a6be696 Mon Sep 17 00:00:00 2001 From: Abe Levitan Date: Wed, 8 Jun 2022 12:09:03 -0700 Subject: [PATCH] move to a src directory layout --- docs/source/installation.rst | 34 +++++++++---------- conda_requirements.txt => requirements.txt | 0 setup.py | 4 ++- {CDTools => src/CDTools}/__init__.py | 0 {CDTools => src/CDTools}/datasets/__init__.py | 0 {CDTools => src/CDTools}/datasets/base.py | 0 .../datasets/polarized_ptycho_2d_dataset.py | 0 .../CDTools}/datasets/ptycho_2d_dataset.py | 0 {CDTools => src/CDTools}/models/__init__.py | 0 {CDTools => src/CDTools}/models/base.py | 0 .../CDTools}/models/bragg_2d_ptycho.py | 0 .../CDTools}/models/complex_adam.py | 0 .../CDTools}/models/complex_lbfgs.py | 0 .../CDTools}/models/fancy_ptycho.py | 0 .../CDTools}/models/multimode_rpi.py | 0 .../CDTools}/models/multislice_2d_ptycho.py | 0 .../CDTools}/models/polarized_fancy_ptycho.py | 0 {CDTools => src/CDTools}/models/rpi.py | 0 .../CDTools}/models/s_matrix_ptycho.py | 0 .../CDTools}/models/simple_ptycho.py | 0 .../time_resolved_ptycho_calibration.py | 0 .../CDTools}/models/time_resolved_rpi.py | 0 {CDTools => src/CDTools}/tools/__init__.py | 0 .../CDTools}/tools/analysis/__init__.py | 0 .../CDTools}/tools/analysis/analysis.py | 0 .../CDTools}/tools/atoms/__init__.py | 0 {CDTools => src/CDTools}/tools/atoms/atoms.py | 0 .../CDTools}/tools/data/__init__.py | 0 {CDTools => src/CDTools}/tools/data/data.py | 0 .../tools/image_processing/__init__.py | 0 .../image_processing/image_processing.py | 0 .../CDTools}/tools/initializers/__init__.py | 0 .../tools/initializers/initializers.py | 0 .../CDTools}/tools/interactions/__init__.py | 0 .../tools/interactions/interactions.py | 0 .../CDTools}/tools/losses/__init__.py | 0 .../CDTools}/tools/losses/losses.py | 0 .../CDTools}/tools/measurements/__init__.py | 0 .../tools/measurements/measurements.py | 0 .../CDTools}/tools/plotting/__init__.py | 0 .../CDTools}/tools/plotting/plotting.py | 0 .../CDTools}/tools/polarization/__init__.py | 0 .../tools/polarization/polarization.py | 0 .../CDTools}/tools/propagators/__init__.py | 0 .../CDTools}/tools/propagators/propagators.py | 0 45 files changed, 19 insertions(+), 19 deletions(-) rename conda_requirements.txt => requirements.txt (100%) rename {CDTools => src/CDTools}/__init__.py (100%) rename {CDTools => src/CDTools}/datasets/__init__.py (100%) rename {CDTools => src/CDTools}/datasets/base.py (100%) rename {CDTools => src/CDTools}/datasets/polarized_ptycho_2d_dataset.py (100%) rename {CDTools => src/CDTools}/datasets/ptycho_2d_dataset.py (100%) rename {CDTools => src/CDTools}/models/__init__.py (100%) rename {CDTools => src/CDTools}/models/base.py (100%) rename {CDTools => src/CDTools}/models/bragg_2d_ptycho.py (100%) rename {CDTools => src/CDTools}/models/complex_adam.py (100%) rename {CDTools => src/CDTools}/models/complex_lbfgs.py (100%) rename {CDTools => src/CDTools}/models/fancy_ptycho.py (100%) rename {CDTools => src/CDTools}/models/multimode_rpi.py (100%) rename {CDTools => src/CDTools}/models/multislice_2d_ptycho.py (100%) rename {CDTools => src/CDTools}/models/polarized_fancy_ptycho.py (100%) rename {CDTools => src/CDTools}/models/rpi.py (100%) rename {CDTools => src/CDTools}/models/s_matrix_ptycho.py (100%) rename {CDTools => src/CDTools}/models/simple_ptycho.py (100%) rename {CDTools => src/CDTools}/models/time_resolved_ptycho_calibration.py (100%) rename {CDTools => src/CDTools}/models/time_resolved_rpi.py (100%) rename {CDTools => src/CDTools}/tools/__init__.py (100%) rename {CDTools => src/CDTools}/tools/analysis/__init__.py (100%) rename {CDTools => src/CDTools}/tools/analysis/analysis.py (100%) rename {CDTools => src/CDTools}/tools/atoms/__init__.py (100%) rename {CDTools => src/CDTools}/tools/atoms/atoms.py (100%) rename {CDTools => src/CDTools}/tools/data/__init__.py (100%) rename {CDTools => src/CDTools}/tools/data/data.py (100%) rename {CDTools => src/CDTools}/tools/image_processing/__init__.py (100%) rename {CDTools => src/CDTools}/tools/image_processing/image_processing.py (100%) rename {CDTools => src/CDTools}/tools/initializers/__init__.py (100%) rename {CDTools => src/CDTools}/tools/initializers/initializers.py (100%) rename {CDTools => src/CDTools}/tools/interactions/__init__.py (100%) rename {CDTools => src/CDTools}/tools/interactions/interactions.py (100%) rename {CDTools => src/CDTools}/tools/losses/__init__.py (100%) rename {CDTools => src/CDTools}/tools/losses/losses.py (100%) rename {CDTools => src/CDTools}/tools/measurements/__init__.py (100%) rename {CDTools => src/CDTools}/tools/measurements/measurements.py (100%) rename {CDTools => src/CDTools}/tools/plotting/__init__.py (100%) rename {CDTools => src/CDTools}/tools/plotting/plotting.py (100%) rename {CDTools => src/CDTools}/tools/polarization/__init__.py (100%) rename {CDTools => src/CDTools}/tools/polarization/polarization.py (100%) rename {CDTools => src/CDTools}/tools/propagators/__init__.py (100%) rename {CDTools => src/CDTools}/tools/propagators/propagators.py (100%) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index f34126f..23d3607 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -8,22 +8,22 @@ The source code for CDTools is hosted on it's `MIT github page`_. Access to the .. _`MIT github page`: https://github.mit.edu/Scattering/CDTools -It is recommended that you clone the repository, rather than just downloading the contents, as it remains under rapid development. Cloning the repository will allow you to get access to new updates. +It is recommended that you clone the repository, rather than just downloading the contents, as it remains under development. Cloning the repository will allow you to easily get access to new updates, bug fixes, etc. Step 2: Install Dependencies ---------------------------- -The dependencies for CDTools can be installed, if you are managing your environment with anaconda, by running the following command in the top level directory of the package: +The major dependency for CDTools is pytorch, and because the details of the installation can vary depending on platform, GPU availability, etc, it is recommended that you follow the install instructions on `the pytorch site`_ to install pytorch before the remaining dependencies. + +.. _`the pytorch site`: https://pytorch.org/get-started/locally/ + +If you manage your environment with conda, the remaining dependencies can be installe by running the following command in the top level directory of the package: .. code:: bash - $ conda install --file conda_requirements.txt + $ conda install --file conda_requirements.txt -c conda-forge -One optional dependencies is not installed via this procedure - the dependency sphinx-argparse for building the docs. Sphinx-argparse can either be installed manually via conda-forge, otherwise it will be installed automatically by pip during the final installation step if needed. - -If you manage your environment with pip, all required packges should be installed automatically. The only thing to be aware of is that pytorch must be compiled with MKL support, and CUDA support if you would like to use the GPU. For this reason, using anaconda python is strongly recommended. - -For convenience, the full set of dependencies are noted below: +This will install all dependencies, including optional dependencies for the tests and docs. For convenience, the full set of dependencies are noted below: CDTools depends on the following packages: @@ -41,13 +41,9 @@ And has optional dependencies on * `sphinx-argparse `_ * `sphinx_rtd_theme `_ - -All of these can be installed via pip or conda. Finally, CDTools is NOT python 2 compatible. - -**It is required that pytorch is built with MKL**, as that enables FFTs. Additionally, installing pytorch **with CUDA support** is recommended, if you intend to run any serious reconstructions with the package. - Finally, the optional depencency on pytest enables the tests to be run to confirm a successful installation. Sphinx and sphinx-argparse are only required if you plan on building the documentation. +Finally, CDTools is NOT python 2 compatible. Step 3: Install --------------- @@ -56,21 +52,23 @@ To install in CDTools in developer mode (recommended, to allow any updates to be .. code:: bash - $ pip install -e .[tests,docs] + $ pip install -e . --no-deps -If you don't need to run the tests, or don't need to build the docs, you can omit the relevant option or options. +To install normally (not in developer mode), run: -If you prefer to use a tool other than pip, CDTools can be installed via any other package management tool that works with a setup.py file. +.. code:: bash + + $ pip install . --no-deps Step 4: Run The Tests --------------------- -To ensure that the installation has worked correctly, it is recommended, although not required, that you run the unit tests. After ensuring that pytest is installed, run the following command from the top level directory: +To ensure that the installation has worked correctly, it is recommended that you run the unit tests. After ensuring that pytest is installed, run the following command from the top level directory: .. code:: bash $ pytest -If any tests fail, make sure that you have all the noted dependencies properly installed (specifically that pytorch is installed with MKL support). If so, `shoot me an email `_ and we'll get to the bottom of it. +If any tests fail, make sure that you have all the noted dependencies properly installed, and particularly that pytorch was installed with FFT support. If so, `shoot me an email `_ or open an issue on the github page and we'll get to the bottom of it. diff --git a/conda_requirements.txt b/requirements.txt similarity index 100% rename from conda_requirements.txt rename to requirements.txt diff --git a/setup.py b/setup.py index 9c8cd79..3c9d29f 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="CDTools", version="0.1.1", - python_requires='>3.4', # we use pathlib, introduced in 3.4 + python_requires='>3.7', # recommended minimum version for pytorch author="Abe Levitan", author_email="alevitan@mit.edu", description="Coherent Diffraction Tools", @@ -24,9 +24,11 @@ setuptools.setup( 'tests': ["pytest"], 'docs': ["sphinx","sphinx-argparse","sphinx_rtd_theme"] }, + package_dir={"": "src"}, packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "Operating System :: OS Independent", ], ) + diff --git a/CDTools/__init__.py b/src/CDTools/__init__.py similarity index 100% rename from CDTools/__init__.py rename to src/CDTools/__init__.py diff --git a/CDTools/datasets/__init__.py b/src/CDTools/datasets/__init__.py similarity index 100% rename from CDTools/datasets/__init__.py rename to src/CDTools/datasets/__init__.py diff --git a/CDTools/datasets/base.py b/src/CDTools/datasets/base.py similarity index 100% rename from CDTools/datasets/base.py rename to src/CDTools/datasets/base.py diff --git a/CDTools/datasets/polarized_ptycho_2d_dataset.py b/src/CDTools/datasets/polarized_ptycho_2d_dataset.py similarity index 100% rename from CDTools/datasets/polarized_ptycho_2d_dataset.py rename to src/CDTools/datasets/polarized_ptycho_2d_dataset.py diff --git a/CDTools/datasets/ptycho_2d_dataset.py b/src/CDTools/datasets/ptycho_2d_dataset.py similarity index 100% rename from CDTools/datasets/ptycho_2d_dataset.py rename to src/CDTools/datasets/ptycho_2d_dataset.py diff --git a/CDTools/models/__init__.py b/src/CDTools/models/__init__.py similarity index 100% rename from CDTools/models/__init__.py rename to src/CDTools/models/__init__.py diff --git a/CDTools/models/base.py b/src/CDTools/models/base.py similarity index 100% rename from CDTools/models/base.py rename to src/CDTools/models/base.py diff --git a/CDTools/models/bragg_2d_ptycho.py b/src/CDTools/models/bragg_2d_ptycho.py similarity index 100% rename from CDTools/models/bragg_2d_ptycho.py rename to src/CDTools/models/bragg_2d_ptycho.py diff --git a/CDTools/models/complex_adam.py b/src/CDTools/models/complex_adam.py similarity index 100% rename from CDTools/models/complex_adam.py rename to src/CDTools/models/complex_adam.py diff --git a/CDTools/models/complex_lbfgs.py b/src/CDTools/models/complex_lbfgs.py similarity index 100% rename from CDTools/models/complex_lbfgs.py rename to src/CDTools/models/complex_lbfgs.py diff --git a/CDTools/models/fancy_ptycho.py b/src/CDTools/models/fancy_ptycho.py similarity index 100% rename from CDTools/models/fancy_ptycho.py rename to src/CDTools/models/fancy_ptycho.py diff --git a/CDTools/models/multimode_rpi.py b/src/CDTools/models/multimode_rpi.py similarity index 100% rename from CDTools/models/multimode_rpi.py rename to src/CDTools/models/multimode_rpi.py diff --git a/CDTools/models/multislice_2d_ptycho.py b/src/CDTools/models/multislice_2d_ptycho.py similarity index 100% rename from CDTools/models/multislice_2d_ptycho.py rename to src/CDTools/models/multislice_2d_ptycho.py diff --git a/CDTools/models/polarized_fancy_ptycho.py b/src/CDTools/models/polarized_fancy_ptycho.py similarity index 100% rename from CDTools/models/polarized_fancy_ptycho.py rename to src/CDTools/models/polarized_fancy_ptycho.py diff --git a/CDTools/models/rpi.py b/src/CDTools/models/rpi.py similarity index 100% rename from CDTools/models/rpi.py rename to src/CDTools/models/rpi.py diff --git a/CDTools/models/s_matrix_ptycho.py b/src/CDTools/models/s_matrix_ptycho.py similarity index 100% rename from CDTools/models/s_matrix_ptycho.py rename to src/CDTools/models/s_matrix_ptycho.py diff --git a/CDTools/models/simple_ptycho.py b/src/CDTools/models/simple_ptycho.py similarity index 100% rename from CDTools/models/simple_ptycho.py rename to src/CDTools/models/simple_ptycho.py diff --git a/CDTools/models/time_resolved_ptycho_calibration.py b/src/CDTools/models/time_resolved_ptycho_calibration.py similarity index 100% rename from CDTools/models/time_resolved_ptycho_calibration.py rename to src/CDTools/models/time_resolved_ptycho_calibration.py diff --git a/CDTools/models/time_resolved_rpi.py b/src/CDTools/models/time_resolved_rpi.py similarity index 100% rename from CDTools/models/time_resolved_rpi.py rename to src/CDTools/models/time_resolved_rpi.py diff --git a/CDTools/tools/__init__.py b/src/CDTools/tools/__init__.py similarity index 100% rename from CDTools/tools/__init__.py rename to src/CDTools/tools/__init__.py diff --git a/CDTools/tools/analysis/__init__.py b/src/CDTools/tools/analysis/__init__.py similarity index 100% rename from CDTools/tools/analysis/__init__.py rename to src/CDTools/tools/analysis/__init__.py diff --git a/CDTools/tools/analysis/analysis.py b/src/CDTools/tools/analysis/analysis.py similarity index 100% rename from CDTools/tools/analysis/analysis.py rename to src/CDTools/tools/analysis/analysis.py diff --git a/CDTools/tools/atoms/__init__.py b/src/CDTools/tools/atoms/__init__.py similarity index 100% rename from CDTools/tools/atoms/__init__.py rename to src/CDTools/tools/atoms/__init__.py diff --git a/CDTools/tools/atoms/atoms.py b/src/CDTools/tools/atoms/atoms.py similarity index 100% rename from CDTools/tools/atoms/atoms.py rename to src/CDTools/tools/atoms/atoms.py diff --git a/CDTools/tools/data/__init__.py b/src/CDTools/tools/data/__init__.py similarity index 100% rename from CDTools/tools/data/__init__.py rename to src/CDTools/tools/data/__init__.py diff --git a/CDTools/tools/data/data.py b/src/CDTools/tools/data/data.py similarity index 100% rename from CDTools/tools/data/data.py rename to src/CDTools/tools/data/data.py diff --git a/CDTools/tools/image_processing/__init__.py b/src/CDTools/tools/image_processing/__init__.py similarity index 100% rename from CDTools/tools/image_processing/__init__.py rename to src/CDTools/tools/image_processing/__init__.py diff --git a/CDTools/tools/image_processing/image_processing.py b/src/CDTools/tools/image_processing/image_processing.py similarity index 100% rename from CDTools/tools/image_processing/image_processing.py rename to src/CDTools/tools/image_processing/image_processing.py diff --git a/CDTools/tools/initializers/__init__.py b/src/CDTools/tools/initializers/__init__.py similarity index 100% rename from CDTools/tools/initializers/__init__.py rename to src/CDTools/tools/initializers/__init__.py diff --git a/CDTools/tools/initializers/initializers.py b/src/CDTools/tools/initializers/initializers.py similarity index 100% rename from CDTools/tools/initializers/initializers.py rename to src/CDTools/tools/initializers/initializers.py diff --git a/CDTools/tools/interactions/__init__.py b/src/CDTools/tools/interactions/__init__.py similarity index 100% rename from CDTools/tools/interactions/__init__.py rename to src/CDTools/tools/interactions/__init__.py diff --git a/CDTools/tools/interactions/interactions.py b/src/CDTools/tools/interactions/interactions.py similarity index 100% rename from CDTools/tools/interactions/interactions.py rename to src/CDTools/tools/interactions/interactions.py diff --git a/CDTools/tools/losses/__init__.py b/src/CDTools/tools/losses/__init__.py similarity index 100% rename from CDTools/tools/losses/__init__.py rename to src/CDTools/tools/losses/__init__.py diff --git a/CDTools/tools/losses/losses.py b/src/CDTools/tools/losses/losses.py similarity index 100% rename from CDTools/tools/losses/losses.py rename to src/CDTools/tools/losses/losses.py diff --git a/CDTools/tools/measurements/__init__.py b/src/CDTools/tools/measurements/__init__.py similarity index 100% rename from CDTools/tools/measurements/__init__.py rename to src/CDTools/tools/measurements/__init__.py diff --git a/CDTools/tools/measurements/measurements.py b/src/CDTools/tools/measurements/measurements.py similarity index 100% rename from CDTools/tools/measurements/measurements.py rename to src/CDTools/tools/measurements/measurements.py diff --git a/CDTools/tools/plotting/__init__.py b/src/CDTools/tools/plotting/__init__.py similarity index 100% rename from CDTools/tools/plotting/__init__.py rename to src/CDTools/tools/plotting/__init__.py diff --git a/CDTools/tools/plotting/plotting.py b/src/CDTools/tools/plotting/plotting.py similarity index 100% rename from CDTools/tools/plotting/plotting.py rename to src/CDTools/tools/plotting/plotting.py diff --git a/CDTools/tools/polarization/__init__.py b/src/CDTools/tools/polarization/__init__.py similarity index 100% rename from CDTools/tools/polarization/__init__.py rename to src/CDTools/tools/polarization/__init__.py diff --git a/CDTools/tools/polarization/polarization.py b/src/CDTools/tools/polarization/polarization.py similarity index 100% rename from CDTools/tools/polarization/polarization.py rename to src/CDTools/tools/polarization/polarization.py diff --git a/CDTools/tools/propagators/__init__.py b/src/CDTools/tools/propagators/__init__.py similarity index 100% rename from CDTools/tools/propagators/__init__.py rename to src/CDTools/tools/propagators/__init__.py diff --git a/CDTools/tools/propagators/propagators.py b/src/CDTools/tools/propagators/propagators.py similarity index 100% rename from CDTools/tools/propagators/propagators.py rename to src/CDTools/tools/propagators/propagators.py