Thank you for your interest in contributing! Here are some guidelines:
Install the package locally using pip and in editable mode. This way, you can immediately test your changes to the codebase.
pip install -e .[dev,docs]
The documentation is built using MkDocs. To build the documentation locally, run:
mkdocs serve
Please make sure that all markdown is rendered correctly, and all links are working.
- Fork and clone this repository
- Create a branch
git checkout -b method/fancy-method
for your new method. - Create a folder for the new method in
ldctbench/methods
. The folder must contain the following files__init__.py
argparser.py
: Should implement a methodadd_args()
that takes as input anargparse.ArgumentParser
, adds custom arguments and returns it. If your method has an argumentfancy_arg
, thenargparser.py
should look like this:from argparse import ArgumentParser def add_args(parser: ArgumentParser) -> ArgumentParser: parser.add_argument( "--fancy_arg", type=float, help="My fancy argument." ) return parser
network.py
: Should implement the model asclass Model(torch.nn.Module)
.Trainer.py
: Should imeplement aTrainer
class. This class should be initialized withTrainer(args: argparse.Namespace, device: torch.device)
and implement afit()
method that trains the network. A base class is provided inmethods/base.py
.
- Add the method to
METHODS
inargparser.py
. - Add the method to
docs/denoising_algorithms.md
. - Add a
fancy-method.yaml
config file containing all hyperparameters toconfigs/
.
-
Fork and clone this repository
-
Create a new branch based on your change type:
fix/some-fix
for bug fixesfeat/some-feature
for adding new features
git checkout -b <your-branch-name>
Make sure your code is:
- Readable
- Nicely documented with docstrings in numpy format
- Follows the style guide enforced by black, isort, and flake8
For new methods or features, always implement some unit tests and put them in tests/module/test_new_feature.py
. The test function names should be descriptive. A good format would be something like test_functionname_when_given_arguments_return_x()
. A bad format would be something like test123()
.
Don't do!
# The new "feature" we implemented
def divide(a, b):
# This function divides stuff
if b == 0:
raise ZeroDivisionError("You can't divide by zero!")
return a / b
# Test functions
def test1():
assert divide(1, 2) == 0.5
assert divide(5, 5) == 1.
def test2():
assert divide(5, -2) == -2.5
assert divide(-2, 5) == -0.4
Do!
# The new "feature" we implemented
def divide(a: int, b: int) -> float:
"""Function to divide two numbers
Parameters
----------
a : int
The numerator
b : int
The denominator
Returns
-------
float
Result of division operation
Raises
------
ZeroDivisionError
If the denominator (b) is zero
"""
if b == 0:
raise ZeroDivisionError("You can't divide by zero!")
return a / b
# Test functions
import pytest
def test_divide_when_given_positive_numbers_returns_correct_result():
assert divide(1, 2) == 0.5
assert divide(5, 5) == 1.
def test_divide_when_given_negative_numbers_returns_correct_result():
assert divide(5, -2) == -2.5
assert divide(-2, 5) == -0.4
def test_divide_when_given_zero_denominator_raises_error():
with pytest.raises(ZeroDivisionError):
divide(1, 0)
Before starting a pull request:
- Ensure all tests pass:
poe test
- Ensure that the code is formatted correctly:
poe format_check
- Fix any formatting errors with:
poe format
Alternatively, you can run 1 & 2 in one command using poe verify
Once ready, start a pull request on GitHub and include:
- A clear description of what you're fixing/adding
- Any relevant context or background information
Our pipeline will automatically check your pull request for formatting errors and test results. If you contributed a novel method, it would be great if you can also provide pretrained weights.