Skip to content

Commit 7a1f9e3

Browse files
authored
Merge pull request #357 from coding-for-reproducible-research/data_science_best_practice_short_course
[WIP] Data Science Best Practice Short Course
2 parents 2a2240d + 6523932 commit 7a1f9e3

File tree

7 files changed

+644
-0
lines changed

7 files changed

+644
-0
lines changed

_toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ parts:
343343
- file: short_courses/r_environments
344344
- file: short_courses/r_functions
345345
- file: short_courses/r_unit_testing
346+
- file: short_courses/best_practices
347+
sections:
348+
- file: short_courses/data_science_best_practices
346349
- caption: Join Us!
347350
chapters:
348351
- file: contributing/community

short_courses/best_practices.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Best Practices
2+
3+
This section contains our short, focused Best Practices courses designed to help you quickly develop specific skills without committing to a full workshop series.
4+
5+
## Included modules
6+
- **Data Science Best Practices** – Learn how to set up and manage Python environments for reproducible workflows. [Clickable Link to Self Study Notes](data_science_best_practices.md)
7+
8+
9+
## Who is this for?
10+
Learners who want to quickly enhance their skills in targeted areas, or refresh their knowledge on specific topics.
11+
12+
## How to use these notes
13+
Work through the materials in sequence or jump directly to the topic you need. Each module is self-contained and can be completed independently.

short_courses/data_science_best_practices.md

Lines changed: 536 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[tool.poetry]
2+
name = "{project-name}"
3+
version = "1.0.0"
4+
description = "A brief description of your project."
5+
authors = ["Your Name <[email protected]>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
packages = [
9+
{ include = "{project-name}", from = "src" }
10+
]
11+
12+
# Main project dependencies
13+
[tool.poetry.dependencies]
14+
python = "^3.8"
15+
# Example dependencies (add your specific requirements)
16+
numpy = "^1.21"
17+
pandas = "^1.3"
18+
19+
# Development dependencies
20+
[tool.poetry.dev-dependencies]
21+
pytest = "^6.2" # for testing
22+
jupyter = "^1.0.0" # for running notebooks in the examples folder
23+
24+
# Scripts can also be specified here if necessary
25+
# Defining a script
26+
[tool.poetry.scripts]
27+
example-script = "scripts.example_module:main_function"
28+
# can be run with: poetry run example-script
29+
30+
31+
[build-system]
32+
requires = ["poetry-core>=1.0.0"]
33+
build-backend = "poetry.core.masonry.api"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"python.pythonPath": ".venv/bin/python", // Ensure VSCode uses Poetry's virtual environment
3+
"python.linting.enabled": true, // Enable linting
4+
"python.linting.ruffEnabled": true, // Enable Ruff as the linter
5+
"python.linting.ruffPath": ".venv/bin/ruff", // Point to Ruff inside Poetry's virtual environment
6+
"python.formatting.provider": "black", // Use black for auto-formatting
7+
"python.formatting.blackPath": ".venv/bin/black", // Ensure black from Poetry's virtual environment is used
8+
"python.testing.pytestEnabled": true, // Enable pytest for testing
9+
"python.testing.pytestArgs": [
10+
"tests" // Specify the test folder for pytest
11+
],
12+
"files.exclude": {
13+
"**/.venv": true, // Exclude .venv folder from the file explorer
14+
"**/__pycache__": true // Exclude __pycache__ from the file explorer
15+
},
16+
"editor.formatOnSave": true, // Automatically format on save
17+
"editor.defaultFormatter": "ms-python.black", // Set black as the default formatter
18+
"python.testing.autoTestDiscoverOnSaveEnabled": true // Automatically discover tests on file save
19+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# tests/test_advanced.py
2+
3+
import pytest
4+
5+
class ExampleTestClass:
6+
# Class-level setup and teardown (executed once for the entire class)
7+
@classmethod
8+
def setup_class(cls):
9+
print("\nClass-level setup")
10+
cls.class_resource = "Class resource setup"
11+
12+
@classmethod
13+
def teardown_class(cls):
14+
print("\nClass-level teardown")
15+
cls.class_resource = None
16+
17+
# Object-level setup and teardown (executed before each test method)
18+
def setup_method(self):
19+
print("\nObject-level setup")
20+
self.test_resource = "Test resource setup"
21+
22+
def teardown_method(self):
23+
print("\nObject-level teardown")
24+
self.test_resource = None
25+
26+
def test_addition(self):
27+
assert 1 + 1 == 2
28+
print(f"Using {self.test_resource}")
29+
30+
def test_subtraction(self):
31+
assert 2 - 1 == 1
32+
print(f"Using {self.test_resource}")
33+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# tests/test_simple.py
2+
3+
def test_addition():
4+
assert 1 + 1 == 2
5+
6+
def test_subtraction():
7+
assert 2 - 1 == 1

0 commit comments

Comments
 (0)