🍅 Understanding the core concepts of TomatoPy will help you make the most of the library. This guide introduces the fundamental ideas and components. 🥫
🍕 🍕
Ingredients are the building blocks of TomatoPy. Each ingredient has properties that affect how it behaves during cooking operations.
from tomatopy import Ingredient
# Create a basic ingredient
tomato = Ingredient(
name="tomato",
amount=1,
unit="whole",
properties={
"ripeness": 0.8,
"water_content": 0.95,
"sugar_content": 0.03
}
)
The Kitchen class represents your virtual cooking environment. It manages cooking operations and maintains environmental conditions.
from tomatopy import Kitchen
kitchen = Kitchen()
kitchen.set_temperature(180) # Celsius
kitchen.set_humidity(65) # Percentage
Recipes combine multiple ingredients and define how they should be prepared.
from tomatopy import Recipe
# Create a recipe
marinara = Recipe("Classic Marinara")
marinara.add_ingredient(tomato)
marinara.set_cooking_method("simmer")
marinara.set_duration("30m")
Ingredients have properties that affect their behavior:
Physical Properties: weight, volume, density
Chemical Properties: pH, water content, sugar content
Culinary Properties: ripeness, freshness, texture
# Access and modify properties
print(tomato.properties["water_content"]) # 0.95
tomato.properties["ripeness"] = 0.9
Cooking operations transform ingredients through various methods:
Heat Application: simmering, boiling, roasting
Mechanical Action: chopping, blending, kneading
Chemical Changes: fermentation, curing
# Perform cooking operations
sauce = kitchen.cook(
tomato,
method="simmer",
temperature=100,
duration="30m"
)
Ingredients maintain state throughout cooking operations:
# Check ingredient state
print(tomato.state) # "raw"
sauce = kitchen.cook(tomato, method="simmer")
print(sauce.state) # "cooked"
Ingredients and cooked products have flavor profiles:
from tomatopy import TasteTester
tester = TasteTester()
profile = tester.analyze(sauce)
# Access flavor components
print(profile.acidity) # 0.7
print(profile.sweetness) # 0.3
print(profile.umami) # 0.8
TomatoPy handles unit conversions automatically:
# Convert between units
tomato.convert_to_imperial() # Converts metric to imperial
sauce.convert_volume("ml", "cups") # Converts between volume units
The library includes robust error handling:
try:
kitchen.cook(tomato, temperature=1000) # Too hot!
except TemperatureError as e:
print(f"Error: {e}") # "Temperature exceeds safe cooking range"
Always Use Virtual Environments
python -m venv tomatopy-env
source tomatopy-env/bin/activate # or `tomatopy-env\Scripts\activate` on Windows
Check Ingredient Properties Before Cooking
if tomato.properties["ripeness"] < 0.5:
print("Warning: Tomato may be too unripe for optimal results")
Use Type Hints for Better Code
from typing import Dict, Any
def create_ingredient(name: str, properties: Dict[str, Any]) -> Ingredient:
return Ingredient(name=name, properties=properties)
Core Modules - Dive deeper into specific modules
Tutorials - Follow step-by-step guides
API Reference - Explore the full API documentation