Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package a measurement module

This repository contains a small, working Python module. It can be imported while you are in the repository, but it is not an installable project yet.

Your task is to turn it into a minimal src/-layout package while preserving its public functions and behavior.

Establish the baseline

Create or activate an environment and install pytest:

python -m pip install -r requirements-dev.txt

Run the example and tests:

python example.py
python -m pytest

Both should pass. Installation currently fails because the repository has no package metadata:

python -m pip install -e .

Create the package structure

Create this layout:

.
├── pyproject.toml
├── src/
│   └── measurement_tools/
│       ├── __init__.py
│       └── analysis.py
├── example.py
└── tests/
    └── test_measurement_tools.py

Move the existing module rather than copying it:

mkdir -p src/measurement_tools
git mv measurement_tools.py src/measurement_tools/analysis.py

Create src/measurement_tools/__init__.py and import these functions from .analysis so callers can continue importing them directly from measurement_tools:

  • center_measurements
  • mean_measurement

Add minimal project metadata

Create pyproject.toml:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "measurement-tools"
version = "0.1.0"
description = "Small helpers for laboratory measurements"
readme = "README.md"
requires-python = ">=3.11"

[tool.pytest.ini_options]
addopts = "-q"
testpaths = ["tests"]

Install and verify

Install the project in editable mode. Editable installation means that changes under src/ are immediately visible without reinstalling:

python -m pip install -e .
python example.py
python -m pytest
python -c "from measurement_tools import mean_measurement"

Inspect and commit your changes, then submit:

git status
git diff --stat
git add pyproject.toml src
git commit -m "Package measurement tools"
gh student submit

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages