Views
No views yet
1def calculate_total(items, tax_rate=0.08, discount=None):
2 subtotal = sum(item['price'] * item['quantity'] for item in items)
3 if discount:
4 subtotal *= (1 - discount)
5 return subtotal * (1 + tax_rate)1def calculate_total(items, tax_rate=0.08, discount=None):
2 """
3 Calculate the total cost of items, applying a tax rate and optionally a discount.
4
5 Args:
6 items: List of item objects with price and quantity
7 tax_rate: Tax rate expressed as a decimal (default 0.08)
8 discount: Discount rate expressed as a decimal; if provided, the subtotal is multiplied by (1 - discount)
9
10 Returns:
11 Total amount after applying the tax
12
13 Example:
14 >>> items = [{'price': 10, 'quantity': 2}, {'price': 5, 'quantity': 1}]
15 >>> calculate_total(items, tax_rate=0.1, discount=0.05)
16 22.5
17 """
18 subtotal = sum(item['price'] * item['quantity'] for item in items)
19 if discount:
20 subtotal *= (1 - discount)
21 return subtotal * (1 + tax_rate)| Model | Size | Accuracy |
|---|---|---|
| GPT-OSS (thinking) | 120B | 0.81 ± 0.02 |
| Qwen3 0.6B (tuned) | 0.6B | 0.76 ± 0.01 |
| Qwen3 0.6B (base) | 0.6B | 0.55 ± 0.04 |
1# Install Ollama
2curl -fsSL https://ollama.com/install.sh | sh
3
4# Download and build the model
5pip install huggingface_hub
6hf download distil-labs/Distil-Localdoc-Qwen3-0.6B --local-dir distil-model
7cd distil-model
8ollama create localdoc_qwen3 -f Modelfile
9
10# Run on your code
11python localdoc_cli.py --file your_script.py1# Basic usage (generates Google-style docstrings)
2python localdoc_cli.py --file my_module.py
3
4# Use specific model
5python localdoc_cli.py --file my_module.py --model localdoc_qwen3_documented suffix1@software{distil_localdoc_2024,
2 title = {Distil-Localdoc: Local Python Documentation Generation with SLMs},
3 author = {Distil Labs},
4 year = {2024},
5 url = {https://huggingface.co/distil-labs/Distil-Localdoc-Qwen3-0.6B}
6}