The cooking operations module provides a comprehensive set of tools for simulating various cooking methods and processes in TomatoPy.
from tomatopy import Kitchen
# Initialize a kitchen
kitchen = Kitchen()
# Configure basic settings
kitchen.set_temperature(180) # Celsius
kitchen.set_humidity(65) # Percentage
kitchen.set_pressure(101.3) # kPa (atmospheric pressure)
# Configure advanced settings
kitchen.set_ventilation("high")
kitchen.set_lighting("bright")
kitchen.set_equipment({
"stove": {"type": "gas", "burners": 4},
"oven": {"type": "convection", "capacity": "large"},
"blender": {"type": "high_speed", "capacity": "1.5L"}
})
# Simmer ingredients
sauce = kitchen.cook(
tomato,
method="simmer",
temperature=100,
duration="30m",
stirring_frequency="occasional"
)
# Boil ingredients
pasta = kitchen.cook(
spaghetti,
method="boil",
temperature=100,
duration="8m",
salt_concentration=0.02 # 2% salt
)
# Roast ingredients
roasted_tomatoes = kitchen.cook(
tomatoes,
method="roast",
temperature=200,
duration="45m",
turning_frequency="every_15m"
)
# Pressure cook ingredients
beans = kitchen.cook(
dried_beans,
method="pressure_cook",
pressure=103.4, # kPa
temperature=121, # Celsius
duration="30m"
)
# Sous vide cooking
steak = kitchen.cook(
beef,
method="sous_vide",
temperature=55,
duration="2h",
vacuum_sealed=True
)
# Smoke ingredients
smoked_tomatoes = kitchen.cook(
tomatoes,
method="smoke",
temperature=100,
duration="4h",
wood_type="hickory",
smoke_intensity="medium"
)
from tomatopy import Recipe
# Create a recipe
marinara = Recipe("Classic Marinara")
marinara.add_ingredient(tomato)
marinara.add_ingredient(garlic)
marinara.add_ingredient(basil)
# Set cooking parameters
marinara.set_cooking_method("simmer")
marinara.set_duration("30m")
marinara.set_temperature(100)
# Cook multiple recipes
recipes = [marinara, pizza_sauce, tomato_soup]
results = kitchen.cook_batch(recipes)
# Process results
for recipe, result in zip(recipes, results):
print(f"{recipe.name}: {result.consistency}")
# Monitor temperature during cooking
with kitchen.temperature_monitor() as monitor:
sauce = kitchen.cook(tomato, method="simmer")
temperature_history = monitor.get_history()
print(f"Average temperature: {monitor.get_average()}°C")
# Set up temperature alerts
kitchen.set_temperature_alert(
min_temp=95,
max_temp=105,
callback=lambda temp: print(f"Temperature alert: {temp}°C")
)
# Perform safety checks
if kitchen.validate_cooking_parameters(
temperature=200,
duration="2h",
pressure=103.4
):
# Proceed with cooking
result = kitchen.cook(...)
else:
print("Invalid cooking parameters")
# Assess cooking results
quality_report = kitchen.assess_cooking_result(sauce)
print(f"Overall quality: {quality_report.score}")
print(f"Recommendations: {quality_report.recommendations}")
try:
# Attempt invalid cooking operation
kitchen.cook(
tomato,
method="invalid_method",
temperature=1000 # Too hot!
)
except CookingError as e:
print(f"Error: {e}") # "Invalid cooking method"
try:
# Attempt unsafe temperature
kitchen.set_temperature(500) # Too hot!
except TemperatureError as e:
print(f"Error: {e}") # "Temperature exceeds safe range"
Always Validate Parameters
if kitchen.validate_cooking_parameters(
temperature=temp,
duration=duration,
pressure=pressure
):
# Proceed with cooking
Monitor Temperature
with kitchen.temperature_monitor() as monitor:
result = kitchen.cook(...)
if monitor.get_max() > safety_threshold:
print("Warning: Temperature exceeded safety threshold")
Use Appropriate Methods
# Choose method based on ingredient
if ingredient.requires_gentle_cooking:
method = "simmer"
else:
method = "boil"
Kitchen
: Main class for cooking operations
Recipe
: Recipe management class
TemperatureMonitor
: Temperature monitoring class
QualityReport
: Cooking quality assessment class
__init__()
set_temperature(temp)
set_humidity(humidity)
set_pressure(pressure)
set_ventilation(level)
set_lighting(level)
set_equipment(equipment)
cook(ingredient, method, **params)
cook_batch(recipes)
validate_cooking_parameters(**params)
assess_cooking_result(result)
temperature_monitor()
Pizza Creation System - Create delicious pizzas
Taste Testing Module - Analyze cooking results
API Reference - Explore the full API
The ingredient manipulation module provides tools for creating, modifying, and analyzing virtual ingredients in TomatoPy.
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
}
)
from tomatopy import Tomato, Garlic, Basil
# Create specialized ingredients
san_marzano = Tomato(
ripeness=0.8,
variety="San Marzano",
weight=150
)
fresh_garlic = Garlic(
cloves=3,
freshness=0.9,
size="medium"
)
sweet_basil = Basil(
leaves=10,
freshness=0.95,
variety="Genovese"
)
# Update ingredient properties
tomato.properties["ripeness"] = 0.9
tomato.properties["water_content"] = 0.92
# Batch update properties
tomato.update_properties({
"ripeness": 0.9,
"water_content": 0.92,
"sugar_content": 0.04
})
# Convert between units
tomato.convert_to_imperial() # Converts metric to imperial
tomato.convert_volume("ml", "cups") # Converts between volume units
# Get measurements in different units
print(tomato.get_weight("g")) # 150
print(tomato.get_weight("oz")) # 5.29
# Get physical properties
print(tomato.get_density()) # 1.02 g/ml
print(tomato.get_volume()) # 147 ml
print(tomato.get_surface_area()) # 150 cm²
# Analyze chemical properties
print(tomato.get_ph()) # 4.5
print(tomato.get_water_content()) # 0.95
print(tomato.get_sugar_content()) # 0.03
# Cut ingredients
diced_tomato = tomato.cut(
method="dice",
size="medium",
consistency="uniform"
)
# Chop ingredients
chopped_garlic = fresh_garlic.chop(
fineness="medium",
method="mince"
)
# Combine ingredients
mixture = tomato.combine(
fresh_garlic,
sweet_basil,
method="mix",
consistency="chunky"
)
# Check ingredient freshness
if tomato.is_fresh():
print("Ingredient is fresh")
else:
print("Ingredient may be past its prime")
# Get freshness score
freshness_score = tomato.get_freshness_score() # 0.85
# Assess ingredient quality
quality_report = tomato.assess_quality()
print(quality_report.overall_score) # 0.92
print(quality_report.recommendations) # ["Consider using within 2 days"]
try:
# Attempt invalid operation
tomato.cut(method="invalid_method")
except IngredientError as e:
print(f"Error: {e}") # "Invalid cutting method"
try:
# Attempt invalid property update
tomato.update_properties({"invalid_property": 1.0})
except PropertyError as e:
print(f"Error: {e}") # "Invalid property name"
Always Check Ingredient State
if tomato.state == "fresh":
# Proceed with operation
Use Type Hints
from typing import Dict, Any
def create_ingredient(
name: str,
properties: Dict[str, Any]
) -> Ingredient:
return Ingredient(name=name, properties=properties)
Handle Unit Conversions Carefully
# Always specify units explicitly
weight_grams = tomato.get_weight("g")
weight_ounces = tomato.get_weight("oz")
Ingredient
: Base class for all ingredients
Tomato
: Specialized tomato ingredient
Garlic
: Specialized garlic ingredient
Basil
: Specialized basil ingredient
__init__(name, amount, unit, properties)
update_properties(properties)
convert_to_imperial()
convert_volume(from_unit, to_unit)
get_density()
get_volume()
get_surface_area()
get_ph()
get_water_content()
get_sugar_content()
cut(method, size, consistency)
chop(fineness, method)
combine(*ingredients, method, consistency)
is_fresh()
get_freshness_score()
assess_quality()
Cooking Operations - Learn about cooking methods
Pizza Creation System - Create delicious pizzas
API Reference - Explore the full API
The Pizza Creation System provides specialized tools for creating and customizing virtual pizzas in TomatoPy.
from tomatopy import Pizza, PizzaDough, PizzaSauce
# Create pizza components
dough = PizzaDough(
thickness="medium",
size="12inch",
style="neapolitan"
)
sauce = PizzaSauce(
base="tomato",
consistency="smooth",
seasoning_level="medium"
)
# Create a pizza
pizza = Pizza(
dough=dough,
sauce=sauce,
size="12inch",
style="neapolitan"
)
from tomatopy import Topping
# Create toppings
mozzarella = Topping(
name="mozzarella",
amount=200, # grams
distribution="even"
)
basil = Topping(
name="basil",
amount=10, # leaves
distribution="scattered"
)
# Add toppings to pizza
pizza.add_topping(mozzarella)
pizza.add_topping(basil)
# Create custom dough
custom_dough = PizzaDough(
thickness="thin",
size="14inch",
style="new_york",
hydration=0.65, # 65% hydration
fermentation_time="24h",
flour_type="00",
salt_content=0.02 # 2% salt
)
# Create custom sauce
custom_sauce = PizzaSauce(
base="tomato",
consistency="chunky",
seasoning_level="high",
herbs=["basil", "oregano"],
garlic_content=0.05, # 5% garlic
sugar_content=0.02 # 2% sugar
)
from tomatopy import PizzaOven
# Set up pizza oven
oven = PizzaOven(
temperature=450, # Celsius
heat_source="wood",
humidity=0.65
)
# Bake pizza
baked_pizza = oven.bake(
pizza,
duration="2m",
rotation_frequency="30s"
)
# Configure advanced baking
baked_pizza = oven.bake(
pizza,
duration="2m",
rotation_frequency="30s",
heat_zones={
"center": 450,
"edges": 480,
"top": 460
},
steam_injection=True,
crust_development="high"
)
# Analyze pizza quality
analysis = pizza.analyze()
print(f"Crust crispness: {analysis.crust_crispness}")
print(f"Cheese melt: {analysis.cheese_melt}")
print(f"Topping distribution: {analysis.topping_distribution}")
# Get detailed quality metrics
metrics = pizza.get_quality_metrics()
print(f"Overall score: {metrics.overall_score}")
print(f"Balance score: {metrics.balance_score}")
print(f"Texture score: {metrics.texture_score}")
# Create authentic Neapolitan pizza
neapolitan = Pizza.create_neapolitan(
size="12inch",
toppings=["san_marzano_tomatoes", "mozzarella", "basil"]
)
# Create New York style pizza
ny_style = Pizza.create_ny_style(
size="18inch",
thickness="thin",
toppings=["tomato_sauce", "mozzarella", "pepperoni"]
)
# Create Chicago deep dish
chicago = Pizza.create_chicago_style(
size="10inch",
thickness="deep",
toppings=["tomato_sauce", "mozzarella", "sausage"]
)
# Cut pizza into slices
slices = pizza.cut(
method="standard",
slices=8,
slice_size="equal"
)
# Custom pizza cutting
slices = pizza.cut(
method="custom",
slice_sizes=["large", "medium", "small"],
pattern="radial"
)
try:
# Attempt invalid topping
pizza.add_topping("invalid_topping")
except ToppingError as e:
print(f"Error: {e}") # "Invalid topping type"
try:
# Attempt invalid baking temperature
oven.set_temperature(1000) # Too hot!
except TemperatureError as e:
print(f"Error: {e}") # "Temperature exceeds safe range"
Proper Dough Preparation
# Ensure proper dough fermentation
if dough.fermentation_time < "24h":
print("Warning: Dough may not be fully fermented")
Topping Distribution
# Check topping distribution
if pizza.get_topping_distribution() < 0.8:
print("Warning: Toppings may not be evenly distributed")
Temperature Control
# Monitor oven temperature
with oven.temperature_monitor() as monitor:
pizza = oven.bake(...)
if monitor.get_max() > 500:
print("Warning: Oven temperature too high")
Pizza
: Main pizza class
PizzaDough
: Dough management class
PizzaSauce
: Sauce management class
Topping
: Topping management class
PizzaOven
: Oven management class
__init__(dough, sauce, size, style)
add_topping(topping)
remove_topping(topping)
cut(method, **params)
analyze()
get_quality_metrics()
create_neapolitan(**params)
create_ny_style(**params)
create_chicago_style(**params)
Taste Testing Module - Analyze pizza taste
Kitchen Hardware Interface - Control pizza equipment
API Reference - Explore the full API
The Taste Testing Module provides tools for analyzing and comparing the flavor profiles of ingredients and cooked products in TomatoPy.
Use Appropriate Analysis Depth
Validate Results
Handle Edge Cases
TasteTester
: Main taste testing class
TasteProfile
: Taste profile data class
AromaProfile
: Aroma profile data class
TextureProfile
: Texture profile data class
QualityProfile
: Quality profile data class
TasteVisualizer
: Visualization class
__init__()
analyze(ingredient, **params)
compare(ingredients, metrics)
analyze_balance(ingredient)
analyze_aroma(ingredient, **params)
analyze_texture(ingredient, **params)
assess_quality(ingredient, **params)
visualize_profile(profile, **params)
- Control kitchen equipment
- Explore the full API
- Learn advanced techniques
from tomatopy import TasteTester
# Create a taste tester
tester = TasteTester()
# Analyze a basic ingredient
profile = tester.analyze(tomato)
# Get basic taste metrics
print(f"Sweetness: {profile.sweetness}")
print(f"Acidity: {profile.acidity}")
print(f"Umami: {profile.umami}")
# Get detailed taste profile
profile = tester.analyze(
ingredient,
depth="comprehensive",
include_aroma=True,
include_texture=True
)
# Access detailed metrics
print(f"Sweetness: {profile.sweetness}")
print(f"Acidity: {profile.acidity}")
print(f"Umami: {profile.umami}")
print(f"Aroma intensity: {profile.aroma.intensity}")
print(f"Texture score: {profile.texture.score}")
# Compare multiple ingredients
comparison = tester.compare(
[tomato1, tomato2, tomato3],
metrics=["sweetness", "acidity", "umami"]
)
# Get comparison results
print(f"Sweetest: {comparison.get_highest('sweetness')}")
print(f"Most acidic: {comparison.get_highest('acidity')}")
print(f"Most umami: {comparison.get_highest('umami')}")
# Analyze taste balance
balance = tester.analyze_balance(sauce)
# Get balance metrics
print(f"Overall balance: {balance.overall_score}")
print(f"Sweet-sour ratio: {balance.sweet_sour_ratio}")
print(f"Umami enhancement: {balance.umami_enhancement}")
# Analyze aroma
aroma_profile = tester.analyze_aroma(tomato)
# Get aroma metrics
print(f"Aroma intensity: {aroma_profile.intensity}")
print(f"Aroma complexity: {aroma_profile.complexity}")
print(f"Primary notes: {aroma_profile.primary_notes}")
# Get detailed aroma profile
aroma_profile = tester.analyze_aroma(
ingredient,
include_secondary_notes=True,
include_tertiary_notes=True
)
# Access detailed aroma metrics
print(f"Primary notes: {aroma_profile.primary_notes}")
print(f"Secondary notes: {aroma_profile.secondary_notes}")
print(f"Tertiary notes: {aroma_profile.tertiary_notes}")
# Analyze texture
texture_profile = tester.analyze_texture(tomato)
# Get texture metrics
print(f"Firmness: {texture_profile.firmness}")
print(f"Juiciness: {texture_profile.juiciness}")
print(f"Overall texture: {texture_profile.overall_score}")
# Get detailed texture profile
texture_profile = tester.analyze_texture(
ingredient,
include_mouthfeel=True,
include_structural_analysis=True
)
# Access detailed texture metrics
print(f"Firmness: {texture_profile.firmness}")
print(f"Juiciness: {texture_profile.juiciness}")
print(f"Mouthfeel: {texture_profile.mouthfeel}")
print(f"Structural integrity: {texture_profile.structural_integrity}")
# Assess quality
quality = tester.assess_quality(tomato)
# Get quality metrics
print(f"Overall quality: {quality.overall_score}")
print(f"Freshness: {quality.freshness}")
print(f"Ripeness: {quality.ripeness}")
# Get comprehensive quality assessment
quality = tester.assess_quality(
ingredient,
include_safety=True,
include_shelf_life=True
)
# Access detailed quality metrics
print(f"Overall quality: {quality.overall_score}")
print(f"Safety score: {quality.safety_score}")
print(f"Shelf life estimate: {quality.shelf_life}")
# Create taste profile visualization
viz = tester.visualize_profile(profile)
# Display visualization
viz.show()
# Create detailed visualization
viz = tester.visualize_profile(
profile,
include_aroma=True,
include_texture=True,
style="radar"
)
# Customize visualization
viz.set_color_scheme("tomato")
viz.set_scale("logarithmic")
viz.show()
try:
# Attempt invalid analysis
tester.analyze("invalid_ingredient")
except TasteError as e:
print(f"Error: {e}") # "Invalid ingredient type"
try:
# Attempt invalid comparison
tester.compare([], metrics=["sweetness"])
except ComparisonError as e:
print(f"Error: {e}") # "No ingredients provided for comparison"
# Choose analysis depth based on needs
if needs_detailed_analysis:
profile = tester.analyze(ingredient, depth="comprehensive")
else:
profile = tester.analyze(ingredient, depth="basic")
# Check result validity
if profile.is_valid():
# Proceed with analysis
print(profile.get_summary())
else:
print("Warning: Analysis may be incomplete")
# Handle special cases
if ingredient.is_overripe():
print("Warning: Ingredient may affect taste analysis")
The Kitchen Hardware Interface provides tools for controlling and monitoring virtual kitchen equipment in TomatoPy.
from tomatopy import KitchenHardware
# Initialize kitchen hardware
hardware = KitchenHardware()
# Initialize specific equipment
oven = hardware.get_oven()
stove = hardware.get_stove()
blender = hardware.get_blender()
# Control oven
oven.set_temperature(180) # Celsius
oven.set_mode("bake")
oven.set_timer("30m")
# Control stove
stove.set_burner(1, temperature=100) # Celsius
stove.set_burner(2, temperature=200)
# Control blender
blender.set_speed("high")
blender.set_duration("1m")
# Configure advanced oven settings
oven.configure(
temperature=180,
mode="convection",
humidity=0.65,
fan_speed="high",
steam_injection=True,
heat_zones={
"top": 190,
"bottom": 170,
"rear": 180
}
)
# Configure advanced stove settings
stove.configure(
burners={
1: {"temperature": 100, "size": "small"},
2: {"temperature": 200, "size": "large"},
3: {"temperature": 150, "size": "medium"},
4: {"temperature": 180, "size": "medium"}
},
griddle_temperature=200,
ventilation="high"
)
# Configure advanced blender settings
blender.configure(
speed="high",
duration="1m",
pulse_pattern="intermittent",
container_size="1.5L",
blade_type="multi-purpose"
)
# Monitor equipment status
print(f"Oven temperature: {oven.get_temperature()}°C")
print(f"Stove burner 1: {stove.get_burner_status(1)}")
print(f"Blender speed: {blender.get_speed()}")
# Set up comprehensive monitoring
with hardware.monitor() as monitor:
# Monitor multiple parameters
monitor.track_temperature(oven)
monitor.track_power_usage(stove)
monitor.track_vibration(blender)
# Get monitoring data
data = monitor.get_data()
print(f"Temperature history: {data.temperature_history}")
print(f"Power usage: {data.power_usage}")
print(f"Vibration levels: {data.vibration_levels}")
# Perform safety checks
if hardware.check_safety():
# Proceed with operation
oven.start()
else:
print("Safety check failed")
# Set up safety monitoring
hardware.set_safety_monitoring(
temperature_limits={
"max": 300, # Celsius
"min": 50
},
power_limits={
"max": 5000, # Watts
"min": 0
},
ventilation_required=True,
emergency_shutdown=True
)
# Check equipment status
status = hardware.check_status()
# Perform basic maintenance
if status.needs_cleaning:
hardware.clean_equipment()
if status.needs_calibration:
hardware.calibrate_equipment()
# Schedule maintenance
hardware.schedule_maintenance(
oven,
tasks=["clean", "calibrate", "inspect"],
frequency="weekly"
)
# Get maintenance history
history = hardware.get_maintenance_history()
print(f"Last cleaning: {history.last_cleaning}")
print(f"Last calibration: {history.last_calibration}")
try:
# Attempt invalid temperature
oven.set_temperature(1000) # Too hot!
except TemperatureError as e:
print(f"Error: {e}") # "Temperature exceeds safe range"
try:
# Attempt invalid operation
blender.set_speed("invalid_speed")
except OperationError as e:
print(f"Error: {e}") # "Invalid speed setting"
Always Check Equipment Status
# Check status before use
if hardware.check_status().is_ready:
# Proceed with operation
oven.start()
else:
print("Equipment not ready")
Monitor Temperature
# Monitor temperature during operation
with hardware.temperature_monitor() as monitor:
oven.start()
if monitor.get_max() > safety_threshold:
print("Warning: Temperature too high")
Regular Maintenance
# Schedule regular maintenance
hardware.schedule_maintenance(
equipment,
tasks=["clean", "calibrate"],
frequency="daily"
)
KitchenHardware
: Main hardware control class
Oven
: Oven control class
Stove
: Stove control class
Blender
: Blender control class
Monitor
: Equipment monitoring class
Maintenance
: Maintenance management class
__init__()
get_oven()
get_stove()
get_blender()
check_safety()
check_status()
monitor()
schedule_maintenance()
get_maintenance_history()
set_safety_monitoring()
API Reference - Explore the full API
Tutorials - Learn advanced techniques
Best Practices - Learn best practices