Skip to content
Merged

Dev #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Please complete the following checklist when submitting a PR. The PR will not be

- [ ] All new features include a unit test.
Make sure that the tests passed and the coverage is
sufficient by running `python run_pytests.py --tests_folder=tests` or
`pytest tests --cov=src --cov-report=term-missing`.
sufficient by running `pytest tests --cov=src --cov-report=term-missing`.
- [ ] All new functions and code are clearly documented.
- [ ] The code is formatted using Black.
You can do this by running `black src tests`.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Jérémie Gince
Copyright 2024 Jeremie Gince

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ The project is constituted by the following parts:
- **.gitattributes**: This file is responsible for setting the git attributes of the project.
- **.gitignore**: This file is responsible for ignoring the files that you don't want to commit to the repository.
A basic one is already provided and should be enough for most of the projects.
- **requirements.txt**: This file is responsible for listing the dependencies of the project.
- **pyproject.toml**: This file is responsible for listing the dependencies of the project and the
configuration of the project.
- **README.md**: This file is responsible for providing information about the project.
Expand All @@ -56,7 +55,6 @@ The project is constituted by the following parts:
Feel free to remove it once you used it.
- **setup.py**: This file is responsible for setting up the project.
- **LICENSE**: This file is responsible for providing the license of the project.
- **run_pytests.py**: This script is used by the github actions to run the tests.

# README TEMPLATE

Expand All @@ -67,7 +65,8 @@ With `python` and `pip` installed, run the following commands to install the dep
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install poetry
python -m poetry install
```

With `poetry` installed, run the following commands to install the dependencies:
Expand Down Expand Up @@ -126,4 +125,4 @@ python docker_files/build_image_and_run.py --mode=<mode>

## Citation
```
```
```
5 changes: 2 additions & 3 deletions change_project_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def update_init_file(args):
content = re.sub(r'__email__ = "(.*?)"', f'__email__ = "{args.email}"', content)
if args.url is not None:
content = re.sub(r'__url__ = "(.*?)"', f'__url__ = "{args.url}"', content)
if args.pakage_name is not None:
if args.package_name is not None:
content = re.sub(r'__package__ = "(.*?)"', f'__package__ = "{args.package_name}"', content)
with open(init_file, "w") as f:
f.write(content)
Expand Down Expand Up @@ -156,7 +156,7 @@ def update_license(args):
with open("LICENSE", "r") as f:
content = f.read()
if args.author is not None:
content = re.sub(r'Copyright (.*?) (.*?)', f'Copyright {datetime.datetime.now().year} {args.author}', content)
content = re.sub(r'Copyright 2024 Jeremie Gince', f'Copyright {datetime.datetime.now().year} {args.author}', content)
with open("LICENSE", "w") as f:
f.write(content)
return 0
Expand Down Expand Up @@ -217,4 +217,3 @@ def main():

if __name__ == '__main__':
sys.exit(main())

10 changes: 0 additions & 10 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import numpy as np
import pytest

from .configs import TEST_SEED

np.random.seed(TEST_SEED)


def get_slow_test_mark():
from .configs import RUN_SLOW_TESTS

return pytest.mark.skipif(
not RUN_SLOW_TESTS,
reason=f"Only run when configs.{RUN_SLOW_TESTS} is True.",
)
3 changes: 0 additions & 3 deletions tests/configs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
N_RANDOM_TESTS_PER_CASE = 10
TEST_SEED = 42

ATOL_MATRIX_COMPARISON = 1e-7
Expand All @@ -12,5 +11,3 @@

ATOL_SHAPE_COMPARISON = 0
RTOL_SHAPE_COMPARISON = 0

RUN_SLOW_TESTS = True
46 changes: 0 additions & 46 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,46 +0,0 @@
import pytest

from .configs import RUN_SLOW_TESTS

RUN_SLOW_ARG_NAME = "run_slow"


@pytest.hookimpl()
def pytest_sessionstart(session):
pass


# @pytest.hookimpl()
# def pytest_sessionfinish(session, exitstatus):
# reporter = session.config.pluginmanager.get_plugin('terminalreporter')
# print('passed amount:', len(reporter.stats['passed']))


def pytest_addoption(parser):
r"""
Add options to the pytest command.

See: https://jwodder.github.io/kbits/posts/pytest-mark-off/.

:param parser: The pytest parser.
:return: None
"""
parser.addoption(
f"--{RUN_SLOW_ARG_NAME}",
action="store_true",
default=RUN_SLOW_TESTS,
help="Run slow tests",
)


def pytest_collection_modifyitems(config, items):
if config.getoption(f"--{RUN_SLOW_ARG_NAME}"):
# if RUN_SLOW_TESTS:
# print("Running slow tests")
pass
else:
# print("Skipping slow tests")
skipper = pytest.mark.skip(reason=f"Only run when '--{RUN_SLOW_ARG_NAME}=True' is given")
for item in items:
if "slow" in item.keywords:
item.add_marker(skipper)
1 change: 0 additions & 1 deletion tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import runpy

import pytest

Expand Down