Skip to content

Commit

Permalink
contributing updated to rst and minor changes in makefile and documen…
Browse files Browse the repository at this point in the history
…tation update
  • Loading branch information
sibirrer committed Aug 15, 2022
1 parent 5ec3998 commit 39ebeb7
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 153 deletions.
144 changes: 0 additions & 144 deletions CONTRIBUTING.md

This file was deleted.

167 changes: 167 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -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 <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:

::

git clone https://github.com/<your-account>/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 <your-branch-name> 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 <your-branch-name>



**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 <your-branch-name>


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 ``<your-account>/lenstronomy`` and the compare branch is ``<your-branch-name>``
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 <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.7 (see `setup.cfg <https://github.com/lenstronomy/lenstronomy/blob/main/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 based e.g. `LensModel <https://lenstronomy.readthedocs.io/en/latest/lenstronomy.LensModel.html>`_, `LightModel <https://lenstronomy.readthedocs.io/en/stable/lenstronomy.LightModel.html>`_ or `ImSim <https://lenstronomy.readthedocs.io/en/latest/lenstronomy.ImSim.html>`_. There is also a `Util <https://lenstronomy.readthedocs.io/en/stable/lenstronomy/Util.html>`_ 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 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.rst>`_.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ pypi-upload:
twine upload dist/*

conda-upload:
grayskull pypi lenstronomy
grayskull pypi lenstronomy
4 changes: 2 additions & 2 deletions PUBLISHED.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://arxiv.org/abs/2111.14882>`_
*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 <https://arxiv.org/abs/2201.08858>`_
* The size-luminosity relation of lensed galaxies at z=6−9 in the Hubble Frontier Fields; `Yang et al. 2022a <https://arxiv.org/abs/2201.08858>`_
*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 <https://arxiv.org/abs/2202.01714>`_
Expand All @@ -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 <https://arxiv.org/abs/2205.04481>`_
*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 <https://arxiv.org/abs/2207.13101>`_
* Early results from GLASS-JWST. V: the first rest-frame optical size-luminosity relation of galaxies at z>7; `Yang et al. 2022b <https://arxiv.org/abs/2207.13101>`_
*galaxy size measurement from JWST data with Galight/lenstronomy*


Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Contributing to lenstronomy
===========================

.. include:: ../CONTRIBUTING.md
.. include:: ../CONTRIBUTING.rst
3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ Contents:
:maxdepth: 2

installation
modules
usage
lenstronomy
contributing
mailinglist
authors
published
affiliatedpackages
history
modules
2 changes: 2 additions & 0 deletions lenstronomy/LensModel/Profiles/cored_steep_ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down
6 changes: 3 additions & 3 deletions lenstronomy/LightModel/Profiles/starlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand All @@ -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))
"""
Expand Down

0 comments on commit 39ebeb7

Please sign in to comment.