Download tests/test_food_batch.py from RenaissanceLabsEU/practice: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/datasets/RenaissanceLabsEU/practice/resolve/main/tests/test_food_batch.py
- Command line
-
hf download hf://datasets/RenaissanceLabsEU/practice/tests/test_food_batch.py
-
curl -L -o test_food_batch.py https://huggingface.co/datasets/RenaissanceLabsEU/practice/resolve/main/tests/test_food_batch.py
1.34 kB
| """Mass-balance examples with explicit arithmetic.""" | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0,str(Path(__file__).resolve().parents[1])) | |
| from envs.food_batch.gen import drying,blending,recipe | |
| # 100kg at 50% moisture -> 50kg dry; at 20% final moisture -> 62.5kg, 37.5kg water removed. | |
| assert drying(100,50,20)==dict(initial_dry_kg=50,retained_dry_kg=50,product_kg=62.5,water_removed_kg=37.5) | |
| # 10% dry loss leaves 45kg dry -> 56.25 product, 38.75 water removed. | |
| a=drying(100,50,20,10);assert a['retained_dry_kg']==45 and a['product_kg']==56.25 and a['water_removed_kg']==38.75 | |
| assert drying(100,20,20)['water_removed_kg']==0 | |
| # 100kg target 20% from 10% and 30%: 50/50kg, component 20kg. | |
| assert blending(100,10,30,20)==dict(charge_kg=100,high_kg=50,low_kg=50,retained_component_kg=20) | |
| # 90kg output, 10% uniform loss -> 100kg charge; target 15% -> high 25kg, low 75kg. | |
| b=blending(90,10,30,15,10);assert b['charge_kg']==100 and b['high_kg']==25 and b['low_kg']==75 and b['retained_component_kg']==13.5 | |
| assert blending(100,0,100,25)['high_kg']==25 | |
| # Charge 100kg, 1:3 recipe -> 25+75kg, costs 2 and 4 -> 350. | |
| assert recipe(100,0,[1,3],[2,4])==(100,[25,75],350) | |
| assert recipe(90,10,[1,3],[2,4])==(100,[25,75],350) | |
| assert recipe(120,0,[1,1,1],[1,2,3])==(120,[40,40,40],240) | |
| print('food_batch: 3 hand-worked cases per family passed') | |