From 39ebeb75ea5874397ea5570ea3c7b6835164f26a Mon Sep 17 00:00:00 2001 From: sibirrer Date: Sun, 14 Aug 2022 21:33:43 -0700 Subject: [PATCH] contributing updated to rst and minor changes in makefile and documentation update --- CONTRIBUTING.md | 144 --------------- CONTRIBUTING.rst | 167 ++++++++++++++++++ Makefile | 2 +- PUBLISHED.rst | 4 +- docs/contributing.rst | 2 +- docs/index.rst | 3 +- .../Profiles/cored_steep_ellipsoid.py | 2 + lenstronomy/LightModel/Profiles/starlets.py | 6 +- 8 files changed, 177 insertions(+), 153 deletions(-) delete mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTING.rst diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 394b4a379..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,144 +0,0 @@ -Contributing to lenstronomy -=========================== - -GitHub Workflow ---------------- - -### Fork and Clone the lenstronomy Repository -**You should only need to do this step once** - -First *fork* the lenstronomy repository. A fork is your own remote copy of the repository on GitHub. To create a fork: - - 1. Go to the [lenstronomy GitHub Repository](https://github.com/lenstronomy/lenstronomy) - 2. Click the **Fork** button (in the top-right-hand corner) - 3. Choose where to create the fork, typically your personal GitHub account - -Next *clone* your fork. Cloning creates a local copy of the repository on your computer to work with. To clone your fork: - - ```bash - git clone https://github.com//lenstronomy.git - ``` - -Finally add the `lenstronomy` repository as a *remote*. This will allow you to fetch changes made to the codebase. To add the `lenstronomyproject` remote: - - ```bash - cd lenstronomy - git remote add lenstronomyproject https://github.com/lenstronomy/lenstronomy.git - ``` - -### Install your local lenstronomy version - -To enable that your new code gets accessible by python also outside of the development environment, -make sure all previous versions of lenstronomy are uninstalled and then install your version of lenstronomy (aka add the software to the python path) - - ```bash - cd lenstronomy - python setup.py develop --user - ``` - -Alternatively, create virtual environments for the development (recommended for advanced usage with multiple branches). - - - -### Create a branch for your new feature - -Create a *branch* off the `lenstronomyproject` main branch. Working on unique branches for each new feature simplifies the development, review and merge processes by maintaining logical separation. To create a feature branch: - - ```bash - git fetch lenstronomyproject - git checkout -b lenstronomyproject/main - ``` - -### Hack away! - -Write the new code you would like to contribute and *commit* it to the feature branch on your local repository. Ideally commit small units of work often with clear and descriptive commit messages describing the changes you made. To commit changes to a file: - - ```bash - git add file_containing_your_contribution - git commit -m 'Your clear and descriptive commit message' - ``` - -*Push* the contributions in your feature branch to your remote fork on GitHub: - - ```bash - git push origin - ``` - - -**Note:** The first time you *push* a feature branch you will probably need to use `--set-upstream origin` to link to your remote fork: - - - ```bash - git push --set-upstream origin - ``` - -### Open a Pull Request - -When you feel that work on your new feature is complete, you should create a *Pull Request*. This will propose your work to be merged into the main lenstronomy repository. - - 1. Go to [lenstronomy Pull Requests](https://github.com/lenstronomy/lenstronomy/pulls) - 2. Click the green **New pull request** button - 3. Click **compare across forks** - 4. Confirm that the base fork is `lenstronomy/lenstronomy` and the base branch is `main` - 5. Confirm the head fork is `/lenstronomy` and the compare branch is `` - 6. Give your pull request a title and fill out the the template for the description - 7. Click the green **Create pull request** button - -### Updating your branch - -As you work on your feature, new commits might be made to the `lenstronomy/lenstronomy` main branch. You will need to update your branch with these new commits before your pull request can be accepted. You can achieve this in a few different ways: - - - If your pull request has no conflicts, click **Update branch** - - If your pull request has conflicts, click **Resolve conflicts**, manually resolve the conflicts and click **Mark as resolved** - - *merge* the `lenstronomyproject` main branch from the command line: - ```bash - git fetch lenstronomyproject - git merge lenstronomyproject/main - ``` - - *rebase* your feature branch onto the `lenstronomy` main branch from the command line: - ```bash - git fetch lenstronomyproject - git rebase lenstronomyproject/main - ``` - -**Warning**: It is bad practice to *rebase* commits that have already been pushed to a remote such as your fork. Rebasing creates new copies of your commits that can cause the local and remote branches to diverge. `git push --force` will **overwrite** the remote branch with your newly rebased local branch. This is strongly discouraged, particularly when working on a shared branch where you could erase a collaborators commits. - -For more information about resolving conflicts see the GitHub guides: - - [Resolving a merge conflict on GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github) - - [Resolving a merge conflict using the command line](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-using-the-command-line) - - [About Git rebase](https://help.github.com/en/github/using-git/about-git-rebase) - -### More Information - -More information regarding the usage of GitHub can be found in the [GitHub Guides](https://guides.github.com/). - -Coding Guidelines ------------------ - -Before your pull request can be merged into the codebase, it will be reviewed by one of the lenstronomy developers and required to pass a number of automated checks. Below are a minimum set of guidelines for developers to follow: - -### General Guidelines - -- lenstronomy is compatible with Python>=3.5 (see [setup.cfg](setup.cfg)). lenstronomy *does not* support backwards compatibility with Python 2.x; `six`, `__future__` and `2to3` should not be used. -- All contributions should follow the [PEP8 Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/). We recommend using [flake8](https://flake8.pycqa.org/) to check your code for PEP8 compliance. -- Importing lenstronomy should only depend on having [NumPy](https://www.numpy.org), [SciPy](https://www.scipy.org/) and [Astropy](https://www.astropy.org/) installed. -- Code is grouped into submodules e.g. [LensModel](lenstronomy/LensModel), [LightModel](lenstronomy/LightModel) and [ImSim](lenstronomy/ImSim). There is also a [Util](lenstronomy/Util) submodule for general utility functions. -- For more information see the [Astropy Coding Guidelines](http://docs.astropy.org/en/latest/development/codeguide.html) - -### Unit Tests - -Pull requests will require existing unit tests to pass before they can be merged. Additionally, new unit tests should be written for all new public methods and functions. Unit tests for each submodule are contained in subdirectories called `tests` and you can run them locally using `python setup.py test`. For more information see the [Astropy Testing Guidelines](https://docs.astropy.org/en/stable/development/testguide.html). - -### Docstrings - -All public classes, methods and functions require docstrings. You can build documentation locally by installing [sphinx-astropy](https://github.com/astropy/sphinx-astropy) and calling `python setup.py build_docs`. Docstrings should include the following sections: - - - Description - - Parameters - - Notes - - Examples - - References - -For more information see the Astropy guide to [Writing Documentation](https://docs.astropy.org/en/stable/development/docguide.html). - -This page is inspired by the Contributions guidelines of the [Skypy project](https://github.com/skypyproject/skypy/blob/main/CONTRIBUTING.md). diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 000000000..2ba13f4f9 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,167 @@ +Contributor Guidelines +====================== + +GitHub Workflow +--------------- + +Fork and Clone the lenstronomy Repository +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +**You should only need to do this step once** + +First *fork* the lenstronomy repository. A fork is your own remote copy of the repository on GitHub. To create a fork: + + 1. Go to the `lenstronomy GitHub Repository `_ + 2. Click the **Fork** button (in the top-right-hand corner) + 3. Choose where to create the fork, typically your personal GitHub account + +Next *clone* your fork. Cloning creates a local copy of the repository on your computer to work with. To clone your fork: + +:: + + git clone https://github.com//lenstronomy.git + + +Finally add the ``lenstronomyproject`` repository as a *remote*. This will allow you to fetch changes made to the codebase. To add the ``lenstronomyproject`` remote: + +:: + + cd lenstronomy + git remote add lenstronomyproject https://github.com/lenstronomy/lenstronomy.git + + + +Install your local lenstronomy version +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +To enable that your new code gets accessible by python also outside of the development environment, +make sure all previous versions of lenstronomy are uninstalled and then install your version of lenstronomy (aka add the software to the python path) + +:: + + cd lenstronomy + python setup.py develop --user + + +Alternatively, create virtual environments for the development (recommended for advanced usage with multiple branches). + + + +Create a branch for your new feature +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Create a *branch* off the `lenstronomyproject` main branch. Working on unique branches for each new feature simplifies the development, review and merge processes by maintaining logical separation. To create a feature branch: + +:: + + git fetch lenstronomyproject + git checkout -b lenstronomyproject/main + + +Hack away! +^^^^^^^^^^ + +Write the new code you would like to contribute and *commit* it to the feature branch on your local repository. Ideally commit small units of work often with clear and descriptive commit messages describing the changes you made. To commit changes to a file: + +:: + + git add file_containing_your_contribution + git commit -m 'Your clear and descriptive commit message' + + +*Push* the contributions in your feature branch to your remote fork on GitHub: + +:: + + git push origin + + + +**Note:** The first time you *push* a feature branch you will probably need to use `--set-upstream origin` to link to your remote fork: + + +:: + + git push --set-upstream origin + + +Open a Pull Request +^^^^^^^^^^^^^^^^^^^ + +When you feel that work on your new feature is complete, you should create a *Pull Request*. This will propose your work to be merged into the main lenstronomy repository. + + 1. Go to `lenstronomy Pull Requests `_ + 2. Click the green **New pull request** button + 3. Click **compare across forks** + 4. Confirm that the base fork is ``lenstronomy/lenstronomy`` and the base branch is ``main`` + 5. Confirm the head fork is ``/lenstronomy`` and the compare branch is ```` + 6. Give your pull request a title and fill out the the template for the description + 7. Click the green **Create pull request** button + +### Updating your branch + +As you work on your feature, new commits might be made to the ``lenstronomy/lenstronomy`` main branch. You will need to update your branch with these new commits before your pull request can be accepted. You can achieve this in a few different ways: + + - If your pull request has no conflicts, click **Update branch** + - If your pull request has conflicts, click **Resolve conflicts**, manually resolve the conflicts and click **Mark as resolved** + - *merge* the ``lenstronomyproject`` main branch from the command line: + :: + + git fetch lenstronomyproject + git merge lenstronomyproject/main + + + - *rebase* your feature branch onto the ``lenstronomy`` main branch from the command line: + + :: + + git fetch lenstronomyproject + git rebase lenstronomyproject/main + + +**Warning**: It is bad practice to *rebase* commits that have already been pushed to a remote such as your fork. +Rebasing creates new copies of your commits that can cause the local and remote branches to diverge. ``git push --force`` will **overwrite** the remote branch with your newly rebased local branch. +This is strongly discouraged, particularly when working on a shared branch where you could erase a collaborators commits. + +For more information about resolving conflicts see the GitHub guides: + - `Resolving a merge conflict on GitHub `_ + - `Resolving a merge conflict using the command line `_ + - `About Git rebase `_ + +More Information +^^^^^^^^^^^^^^^^ + +More information regarding the usage of GitHub can be found in the `GitHub Guides `_. + +Coding Guidelines +----------------- + +Before your pull request can be merged into the codebase, it will be reviewed by one of the lenstronomy developers and required to pass a number of automated checks. Below are a minimum set of guidelines for developers to follow: + +General Guidelines +^^^^^^^^^^^^^^^^^^ + +- lenstronomy is compatible with Python>=3.7 (see `setup.cfg `_). lenstronomy *does not* support backwards compatibility with Python 2.x; `six`, `__future__` and `2to3` should not be used. +- All contributions should follow the `PEP8 Style Guide for Python Code `_. We recommend using `flake8 `__ to check your code for PEP8 compliance. +- Importing lenstronomy should only depend on having `NumPy `_, `SciPy `_ and `Astropy `__ installed. +- Code is grouped into submodules based e.g. `LensModel `_, `LightModel `_ or `ImSim `_. There is also a `Util `_ submodule for general utility functions. +- For more information see the `Astropy Coding Guidelines `_. + + +Unit Tests +^^^^^^^^^^ + +Pull requests will require existing unit tests to pass before they can be merged. Additionally, new unit tests should be written for all new public methods and functions. Unit tests for each submodule are contained in subdirectories called ``tests`` and you can run them locally using ``python setup.py test``. For more information see the [Astropy Testing Guidelines](https://docs.astropy.org/en/stable/development/testguide.html). + +Docstrings +^^^^^^^^^^ + +All public classes, methods and functions require docstrings. You can build documentation locally by installing sphinx and calling ``python setup.py build_docs``. Docstrings should include the following sections: + + - Description + - Parameters + - Notes + - Examples + - References + +For more information see the Astropy guide to `Writing Documentation `_. + +This page is inspired by the Contributions guidelines of the `Skypy project `_. diff --git a/Makefile b/Makefile index 86b7909cc..8240a8ab3 100644 --- a/Makefile +++ b/Makefile @@ -58,4 +58,4 @@ pypi-upload: twine upload dist/* conda-upload: - grayskull pypi lenstronomy \ No newline at end of file + grayskull pypi lenstronomy \ No newline at end of file diff --git a/PUBLISHED.rst b/PUBLISHED.rst index 29c8e0783..60882370d 100644 --- a/PUBLISHED.rst +++ b/PUBLISHED.rst @@ -220,7 +220,7 @@ Galaxy formation and evolution * RELICS: Small Lensed zā‰„5.5 Galaxies Selected as Potential Lyman Continuum Leakers; `Neufeld et al. 2021 `_ *size measurements of high-z lensed galaxies* -* The size-luminosity relation of lensed galaxies at z=6āˆ’9 in the Hubble Frontier Fields; `Yang et al. 2022 `_ +* The size-luminosity relation of lensed galaxies at z=6āˆ’9 in the Hubble Frontier Fields; `Yang et al. 2022a `_ *size measurements of high-z lensed galaxies* * The Near Infrared Imager and Slitless Spectrograph for the James Webb Space Telescope -- II. Wide Field Slitless Spectroscopy; `Willott et al. 2022 `_ @@ -232,7 +232,7 @@ Galaxy formation and evolution * Concordance between observations and simulations in the evolution of the mass relation between supermassive black holes and their host galaxies; `Ding et al. 2022 `_ *galaxy size measurement with quasar decomposition* -* Early results from GLASS-JWST. V: the first rest-frame optical size-luminosity relation of galaxies at z>7; `Yang et al. 2022 `_ +* Early results from GLASS-JWST. V: the first rest-frame optical size-luminosity relation of galaxies at z>7; `Yang et al. 2022b `_ *galaxy size measurement from JWST data with Galight/lenstronomy* diff --git a/docs/contributing.rst b/docs/contributing.rst index acc76f20b..f5d2417bf 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -2,4 +2,4 @@ Contributing to lenstronomy =========================== -.. include:: ../CONTRIBUTING.md \ No newline at end of file +.. include:: ../CONTRIBUTING.rst \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index c56649bf4..593c8e48c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,12 +12,11 @@ Contents: :maxdepth: 2 installation + modules usage - lenstronomy contributing mailinglist authors published affiliatedpackages history - modules diff --git a/lenstronomy/LensModel/Profiles/cored_steep_ellipsoid.py b/lenstronomy/LensModel/Profiles/cored_steep_ellipsoid.py index 12a7fa6f7..65b59f970 100644 --- a/lenstronomy/LensModel/Profiles/cored_steep_ellipsoid.py +++ b/lenstronomy/LensModel/Profiles/cored_steep_ellipsoid.py @@ -19,6 +19,7 @@ class CSE(LensProfileBase): \\kappa(u;s) = \\frac{A}{2(s^2 + \\xi^2)^{3/2}} with + .. math:: \\xi(x, y) = \\sqrt{x^2 + \\frac{y^2}{q^2}} @@ -127,6 +128,7 @@ class CSEMajorAxis(LensProfileBase): \\kappa(u;s) = \\frac{A}{2(s^2 + \\xi^2)^{3/2}} with + .. math:: \\xi(x, y) = \\sqrt{x^2 + \\frac{y^2}{q^2}} diff --git a/lenstronomy/LightModel/Profiles/starlets.py b/lenstronomy/LightModel/Profiles/starlets.py index 35dfbdf69..2c926f06b 100644 --- a/lenstronomy/LightModel/Profiles/starlets.py +++ b/lenstronomy/LightModel/Profiles/starlets.py @@ -53,7 +53,7 @@ def function(self, x, y, amp=None, n_scales=None, n_pixels=None, scale=1, center Follows lenstronomy conventions for light profiles. :param amp: decomposition coefficients ('amp' to follow conventions in other light profile) - This is an ndarray with shape (n_scales, sqrt(n_pixels), sqrt(n_pixels)) or (n_scales*n_pixels,) + This is an ndarray with shape (n_scales, sqrt(n_pixels), sqrt(n_pixels)) or (n_scales*n_pixels,) :param n_scales: number of decomposition scales :param n_pixels: number of pixels in a single scale :return: reconstructed signal as 1D array of shape (n_pixels,) @@ -74,8 +74,8 @@ def function_2d(self, coeffs, n_scales, n_pixels): """ 2D inverse starlet transform from starlet coefficients stored in coeffs - :param coeffs: decomposition coefficients, - ndarray with shape (n_scales, sqrt(n_pixels), sqrt(n_pixels)) + :param coeffs: decomposition coefficients, + ndarray with shape (n_scales, sqrt(n_pixels), sqrt(n_pixels)) :param n_scales: number of decomposition scales :return: reconstructed signal as 2D array of shape (sqrt(n_pixels), sqrt(n_pixels)) """