Skip to content

Commit

Permalink
adding contributors guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski committed Nov 22, 2023
1 parent 244f360 commit a150683
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 4 deletions.
116 changes: 116 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
## py4DSTEM Contributor Guidelines

**Welcome to the py4DSTEM project!**

We are grateful for your interest in contributing to py4DSTEM, an open-source Python library for 4D-STEM data analysis. Your contributions will help us make py4DSTEM a more powerful and versatile tool for the scientific community.

This document outlines the guidelines and expectations for contributors to the py4DSTEM project. Please read it carefully before making any contributions.

### Contribution Types

There are many ways to contribute to py4DSTEM, including:

* **Reporting bugs:** If you encounter a bug in py4DSTEM, please file a bug report on GitHub. Be sure to provide as much detail as possible about the bug, including steps to reproduce it.

* **Submitting feature requests:** If you have a suggestion for a new feature for py4DSTEM, please submit a feature request on GitHub. Describe the feature in detail and explain how it would benefit users.

* **Improving documentation:** py4DSTEM's documentation is always in need of improvement. If you have suggestions for improving the documentation, please submit a pull request or open an issue on GitHub.

* **Developing new code:** If you are a developer, you can contribute to py4DSTEM by writing new code. Please follow the coding guidelines below.

### Coding Guidelines

* **Code style:** py4DSTEM uses the black code formatter and flake8 linter. All code must pass these checks without error before it can be merged. We suggest using `pre-commit` to help ensure any code commited follows these practices, checkout the [setting up developer environment section below](#install). We also try to abide by PEP8 coding style guide where possible.

* **Documentation:** All code should be well-documented, and use Numpy style docstrings. Use docstrings to document functions and classes, add comments to explain complex code both blocks and individual lines; and use informative variable names.

* **Testing:** Ideally all new code should be accompanied by tests using pyTest framework; but at the least we require examples of old and new behaviour caused by the PR. For bug fixes this can be a block of code which currently fails and works with the proposed changes. For new workflows or extensive feature additions,we'd prefer a Jupyter notebook demonstrating the changes for an entire workflow i.e. from loading the input data and saving any processed results.

### Pull Requests

When submitting a pull request, please:

* **Open a corresponding issue:** Before submitting a pull request, open an issue to discuss your changes and get feedback.

* **Write a clear and concise pull request description:** The pull request description should clearly explain the changes you made and why they are necessary.

* **Follow the coding guidelines:** Make sure your code follows the coding guidelines outlined above.

* **Add tests:** If your pull request includes new code, please add unit tests.

* **Address reviewer feedback:** Respond promptly to reviewer feedback and make changes as needed.

### Code Review

All pull requests will be reviewed by project maintainers before they are merged. The maintainers will provide feedback on the code and may ask for changes. Please be respectful of the maintainers' feedback and make changes as needed.

### Code of Conduct

py4DSTEM is committed to providing a welcoming and inclusive environment for all contributors. Please read and follow the py4DSTEM Code of Conduct.

### Acknowledgments

We are grateful to all of the contributors who have made py4DSTEM possible. Your contributions are invaluable to the scientific community.

Thank you for your interest in contributing to py4DSTEM! We look forward to seeing your contributions.


### Setting up the Developer Environment
<a id='install'></a>

1. **Fork the Git repository:** Go to the py4DSTEM GitHub repository and click the "Fork" button. This will create your own copy of the repository on your GitHub account.

2. **Clone the forked repository:** Open your terminal and clone your forked repository to your local machine. Use the following command, replacing `<your-github-username>` with your GitHub username:

```bash
git clone https://github.com/<your-github-username>/py4DSTEM.git
```
**_extra tips_:** Github has an excellent [tutorial](https://docs.github.com/en/get-started/quickstart/fork-a-repo) you can follow to learn mote about for steps one and two.

3. **Create a new branch:** Create a new branch for your development work. This will prevent your changes from affecting the main branch of the repository. Use the following command, replacing `<branch-name>` with a name for your branch, using an informative name can be helpful e.g. `<fixing-virtual-image-bug>`:

```bash
git checkout -b <branch-name>
```

4. **_(Optional)_ Create an anaconda envrionment:** Environments are useful for a number of reasons. They create an isolated environment for each project or task, making it easy to reproduce results, manage dependencies, and collaborate with others. There are a number of different ways to use environments, including anaconda, pipenv, virtualenv, we reccomend [anaconda](https://docs.anaconda.com/free/anaconda/install/index.html).:

```bash
conda create -n py4dstem-dev python=3.10
```


5. **Install py4DSTEM in editable mode:** Navigate to the cloned repository directory and install py4DSTEM in editable mode. This will allow you to make changes to the code and test them without having to reinstall the library. Use the following command:

```bash
conda activate py4DSTEM-dev #optional if using anaconda
pip install -e .
pip install flake8 black # necessary extra dependencies
```

making changes to the code and testing them using your favorite Python IDE or editor.

6. **_(Optional)_ - Using `pre-commit`**: `pre-commit` streamlines code formatting and linting. Essientally it runs black and flake8 on commit for all staged files, and only allows commits if they both pass. To use pre-commit:

```bash
conda activate py4DSTEM-dev
pip install pre-commit # install pre-commit
cd <path-to-your-fork-of-the-py4DSTEM-git-repo> # go to your py4DSTEM repo
pre-commit install # setup pre-commit to work on this repo (it won't affect any other repos), it changes/creates a file in .git/hooks/pre-commit
```
`pre-commit` is now set up and will automatically run flake8 and black when you try and commit code, and will only commit if they pass and will reject the commit if there are errors.

**_extra tips_:**

```bash
# You can call pre commit manually at any time
pre-commit run # will check any staged files
pre-commit run -a # will run on all files in repo
# you can bypass the hook and commit files without the checks
# (this isn't best practice and should be avoided, but there are times it can be useful)
git add file # stage file as usual
git commit -m "you commit message" --no-verify # commit without running checks
git push # push to repo.
```
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Additional information:
- [Installation instructions](#install)
- [The py4DSTEM documentation pages](https://py4dstem.readthedocs.io/en/latest/index.html).
- [Tutorials and example code](https://github.com/py4dstem/py4DSTEM_tutorials)
- [Want to get involved?](#Contributing)
- [Our open access py4DSTEM publication in Microscopy and Microanalysis](https://doi.org/10.1017/S1431927621000477) describing this project and demonstrating a variety of applications.
- [Our open access 4D-STEM review in Microscopy and Microanalysis](https://doi.org/10.1017/S1431927619000497) describing this project and demonstrating a variety of applications.

Expand Down Expand Up @@ -181,16 +182,18 @@ Links to the data used in each notebook are provided in the intro cell of each n


# More information
<a id='Contributing'></a>

## Documentation
## Contributing Guide
We are grateful for your interest in contributing to py4DSTEM. There are many ways to contribute to py4DSTEM, including Reporting bugs, Submitting feature requests, Improving documentation and Developing new code

Our documentation pages are [available here](https://py4dstem.readthedocs.io/en/latest/index.html).
For more information checkout our [Contributors Guide](CONTRIBUTORS.md)


## Documentation

## For contributors
Our documentation pages are [available here](https://py4dstem.readthedocs.io/en/latest/index.html).

Please see [here](https://gist.github.com/bsavitzky/8b1ee4c1244814940e7cff4500535dba).


## Scientific papers which use **py4DSTEM**
Expand Down

0 comments on commit a150683

Please sign in to comment.