Pull requests are always welcome, and we appreciate any help you give.
Note that a code of conduct applies to all spaces managed by the senselab
project, including issues and pull requests. Please see the Code of Conduct for details.
Please use the following workflow when contributing:
- Install poetry and poetry-dynamic-versioning plugin for dynamic versioning:
pipx install poetry
pipx inject poetry "poetry-dynamic-versioning[plugin]"
- Create an issue: Use GitHub to create an issuel, assign it to yourself (and any collaborators) and, if you have access, add it to the Project board.
- Create a branch: Use GitHub's "Create a branch" button from the issue page to generate a branch associated with the issue.
- Clone the repo locally:
git clone https://github.com/sensein/senselab.git
- Checkout locally:
git fetch origin
git checkout <branch-name>
- Install all required dependencies:
poetry install --with dev,docs
- Install pre-commit hooks:
poetry run pre-commit install
- Work locally on the issue branch. Note: The contributed code will be licensed under the same license as the rest of the repository. If you did not write the code yourself, you must ensure the existing license is compatible and include the license information in the contributed files, or obtain permission from the original author to relicense the contributed code.
- Commit and push regularly on your dev branch.
- It is also OK to submit work in progress.
- Please, write unit tests for your code and test it locally:
poetry run pytest
- Please, document your code following Google style guidelines and the example at the end of this document.
You can manually check the documentation automatically generated from the docstrings:
poetry run pdoc src/senselab -t docs_style/pdoc-theme --docformat google
. This command usespdoc
to generate the documentation for you and make it accessible through a web interface. - If you installed the pre-commit hooks properly, some tests and checks will run, and the commit will succeed if all tests pass. If you prefer to run your tests manually, use the following commands:
- Static type checks:
poetry run mypy .
- Code style checks:
poetry run ruff check
- To automatically fix issues:
poetry run ruff check --fix
- To automatically fix issues:
- Spell checking:
poetry run codespell
- Static type checks:
- Add repository secrets: From your github web interface, add the following repository secrets:
CODECOV_TOKEN
(CodeCov),HF_TOKEN
(HuggingFace),PYPI_TOKEN
(Pypi). - Submit a pull request: Once you are done adding your new amazing functionality, submit a pull request to merge the upstream issue branch into the upstream main.
- Don’t worry much about point 9: Just joking, there’s nothing there – just making sure you're paying attention!
This approach ensures that tasks, issues, and branches all have names that correspond. It also facilitates incremental neatly scoped changes since it tends to keep the scope of individual changes narrow.
If you would like to change this workflow, please use the current process to suggest a change to this document.
If you feel that the functionality you have added to senselab requires some extra explanation, or you want to share some of the knowledge you obtained during the process (e.g., you implemented an API for speaker diarization and want to write a brief explanation about what speaker diarization means and how it's generally evaluated), you can contribute to the Biometrics-book!
import statistics
from typing import Dict, List
def calculate_statistics(data: List[float]) -> Dict[str, float]:
"""
Calculate statistics from a list of numbers.
Args:
data (list of float): A list of floating-point numbers.
Returns:
dict: A dictionary containing the mean, median, variance, and standard deviation of the input data.
Raises:
ValueError: If the input data list is empty.
Examples:
>>> calculate_statistics([1, 2, 3, 4, 5])
{'mean': 3.0, 'median': 3.0, 'variance': 2.0, 'std_dev': 1.4142135623730951}
>>> calculate_statistics([2.5, 3.5, 4.5, 5.5, 6.5])
{'mean': 4.5, 'median': 4.5, 'variance': 2.5, 'std_dev': 1.5811388300841898}
Note:
This function assumes the input data list is not empty. An empty list will raise a ValueError.
Todo:
More statistics will be implemented in the future.
"""
if not data:
raise ValueError("The input data list is empty.")
mean = statistics.mean(data)
median = statistics.median(data)
variance = statistics.variance(data)
std_dev = statistics.stdev(data)
return {
'mean': mean,
'median': median,
'variance': variance,
'std_dev': std_dev
}