33This repository provides a * minimal* template for research projects in Python.
44It includes a basic structure for organizing code, results, and documentation,
55and demonstrates how to incorporate good practices in software engineering such
6- as testing and continuous integration. The template is designed to be
7- lightweight such that it can be easily adapted to your specific needs.
6+ as testing, continuous integration, and automated linting and formatting. The
7+ template is designed to be lightweight such that it can be easily adapted to
8+ your specific needs.
89
910** Motivation:** Research projects often grow organically: Experiments
1011accumulate, code gets copied across notebooks, and results become difficult to
@@ -28,14 +29,13 @@ code organized and reliable.
2829 reverted later. It also facilitates collaboration, as multiple people can
2930 work on in different branches and merge their changes together. This
3031 repository is a GitHub template, which means that when you create a new
31- repository based on this template, it will already be set up with * git* for
32+ repository based on this template, it will already be set up with git for
3233 version control.
3334
3435- ** Testing:** Automated tests help ensure that your code behaves as expected.
3536 For example, if you know the expected output of a function for certain
36- inputs, you can write a test that verifies this behavior automatically.
37- This template uses the [ ` pytest `
38- package] ( https://docs.pytest.org/en/stable/ ) for running tests.
37+ inputs, you can write a test that verifies this behavior automatically. This
38+ template uses the pytest package for running tests.
3939
4040- ** Continuous Integration:** Whenever code changes are made, it is useful to
4141 automatically check whether everything still works. This process is called
@@ -63,16 +63,16 @@ code organized and reliable.
6363 - Prefer simple solutions over complex ones.
6464 - Each code unit should only perform a single, clearly defined task (this
6565 is also known as the * Single Responsibility Principle* ).
66- - Write docstrings describing what your code does and what the inputs and
67- outputs are. Here's an example of a simple one-line docstring:
66+ - Write docstrings describing what your code does. Here's an example with a
67+ simple one-line docstring:
6868 ``` python
6969 def add_10 (input_number ):
7070 """ Add 10 to the given number `input_number`."""
7171 return input_number + 10
7272 ```
73- There are different conventions for docstrings that you can
74- adopt, e.g. * Google* or * NumPy* style. But even a simple one - line
75- description is better than no docstring at all . Here ' s an example
73+ There are different conventions for docstrings that you can adopt, e.g.
74+ the * Google* or * NumPy* style. But even a short description as in the
75+ example above is better than no docstring at all .
7676
7777
7878 These small habits make your code easier to understand for collaborators
@@ -85,13 +85,13 @@ code organized and reliable.
8585The repository is organized into four main folders.
8686
8787- ** `source` ** : The `source` folder contains * reusable code* that may be used
88- across * multiple* experiments. Since we want to be able to import this
89- code, it should be organized in Python files (not Jupyter notebooks). Also,
90- since this code is meant to be reused, it should include basic
91- documentation and tests. All files live in `source/ our_library` . This
92- folder can be installed as a local Python package via `pip install - e .`
93- (details in section 3 ). After installation, functions can be imported in
94- experiments like this : `from our_library.some_functions import add_10` .
88+ across * multiple* experiments. Since we want to be able to import this code,
89+ it should be organized in Python files (not Jupyter notebooks). Also, since
90+ this code is meant to be reused, it should include basic documentation and
91+ tests. All files live in `source/ our_library` . This folder can be installed
92+ as a local Python package via `pip install - e .` (details in section 3 ).
93+ After installation, functions can be imported in experiments very
94+ conveniently : `from our_library.some_functions import add_10` .
9595
9696 The `source` folder also contains a `tests` directory for automated
9797 testing. A useful convention is to mirror the structure of the library and
@@ -136,11 +136,11 @@ The repository is organized into four main folders.
136136
137137# # 3. How To Use This Template
138138
139- ** Prerequisites:** To use this template, you need a GitHub account and ` git`
139+ ** Prerequisites:** To use this template, you need a GitHub account and git
140140installed on your local machine. In addition, you need `conda` installed to
141141create and manage the Python environment used in this project. If you want to
142- compile the LaTeX paper, you will also need a LaTeX distribution such as [* TeX
143- Live* ](https:// www.tug.org/ texlive/ ) installed on your machine.
142+ compile the LaTeX paper, you will also need a LaTeX distribution such as [TeX
143+ Live](https:// www.tug.org/ texlive/ ) installed on your machine.
144144
145145If this is the first time you are using this template, it is recommended to
146146work through all of the following steps:
@@ -221,7 +221,8 @@ work through all of the following steps:
221221 the `.pre- commit- config.yaml` file . After this, every time you create a
222222 commit (e.g. via the terminal or an editor like VS Code), the code will be
223223 automatically checked and formatted using Ruff. If issues are found, the
224- commit will be blocked until they are resolved.
224+ commit will be blocked until they are resolved. You can also run the
225+ pre- commit checks manually via `pre- commit run -- all - files` .
225226
2262277 . ** Run the Experiments:** Take a look at the experiments in the `experiments`
227228 folder. Note how reusable code from `source/ our_library` is imported and how
0 commit comments