Skip to content

Commit 6f9185c

Browse files
committed
Setup template
1 parent dd4e32c commit 6f9185c

10 files changed

Lines changed: 103 additions & 0 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### Python
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]
@@ -160,3 +162,7 @@ cython_debug/
160162
# and can be added to the global gitignore or merged into this file. For a more nuclear
161163
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162164
#.idea/
165+
166+
#### Custom
167+
168+
/data/

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"python.testing.unittestArgs": [
3+
"-v",
4+
"-s",
5+
"./tests",
6+
"-p",
7+
"test_*.py"
8+
],
9+
"python.testing.pytestEnabled": false,
10+
"python.testing.unittestEnabled": true,
11+
"[python]": {
12+
"editor.rulers": [88],
13+
"editor.defaultFormatter": "ms-python.black-formatter",
14+
},
15+
"flake8.args": [
16+
"--exclude=analysis/*py",
17+
"--max-line-length=88",
18+
"--ignore=D100, D202, E203, D412, W503",
19+
]
20+
}

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Python analysis template
2+
3+
This repository can be used as a template for data science projects.
4+
After cloning the repository, you can change:
5+
6+
- The repository name
7+
- The name of the VS code workspace file
8+
- Project information in [`pyproject.toml`](pyproject.toml)
9+
10+
## File structure
11+
12+
- Analysis scripts and notebooks should go to [`analysis/`](analysis/)
13+
- Data files should go to [`data/`](data/). By default, files in `data/` are ignored by Git.
14+
- Results/output files (e.g. figures, output data) should go to [`results/`](results/). These files are ignored by Git.
15+
- Reusable functions and modules are stored in the local package [`src/`](src/). The package can be installed in development mode with `pip install -e .`
16+
- Tests for functions in [`src/`](src/) should go to [`tests/`](tests/) and follow the convention `test_*.py`.
17+
18+
19+
## Setup computational environment
20+
21+
To set up the environment with conda, navigate to the repository directory and run the following in the command line:
22+
23+
```
24+
conda create -n myenv python=3.11
25+
conda activate myenv
26+
pip install -e .
27+
```
28+
29+
## Development environment
30+
31+
I usually work with Visual Studio code, and I have predefined some settings.
32+
In particular, I use:
33+
34+
- [Black](https://black.readthedocs.io/en/stable/index.html) for formatting.
35+
- Flake8 for linting.
36+
- [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) to document functions and classes, with the help of the autoDocstring extension.

analysis/.gitkeep

Whitespace-only changes.

myproject.code-workspace

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {
8+
"autoDocstring.docstringFormat": "google",
9+
}
10+
}

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[build-system]
2+
requires = ["setuptools >= 64"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "src"
7+
version = "0.0.1"
8+
description = ""
9+
authors = [
10+
{name = "Guillem Hurault", email = "guillem.hurault@hotmail.fr"}
11+
]
12+
readme = "README.md"
13+
license = {file = "LICENSE"}
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
]
17+
# dependencies = []
18+
requires-python = ">=3.8"
19+
20+
[project.urls]
21+
# Homepage = ""
22+
# Documentation = ""
23+
# Repository = ""
24+
# Issues = ""

results/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore everything except this file
2+
!.gitignote

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Keep setup.py to facilitate local package installation in editable mode
2+
3+
from setuptools import find_packages, setup
4+
5+
setup(name="src", packages=find_packages())

src/__init__.py

Whitespace-only changes.

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)