Taste Testing Module
The Taste Testing Module provides tools for analyzing and comparing the flavor profiles of ingredients and cooked products in TomatoPy.
Basic Taste Analysis
Simple Taste Testing
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}")
Comprehensive Analysis
# 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}")
Advanced Taste Analysis
Flavor Profile Comparison
# 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')}")
Taste Balance Analysis
# 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}")
Aroma Analysis
Basic Aroma Testing
# 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}")
Detailed Aroma Analysis
# 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}")
Texture Analysis
Basic Texture Testing
# 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}")
Detailed Texture Analysis
# 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}")
Quality Assessment
Basic Quality Testing
# 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}")
Comprehensive Quality Assessment
# 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}")
Taste Profile Visualization
Basic Visualization
# Create taste profile visualization
viz = tester.visualize_profile(profile)
# Display visualization
viz.show()
Advanced Visualization
# 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()
Error Handling
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"
Best Practices
Use Appropriate Analysis Depth
# Choose analysis depth based on needs if needs_detailed_analysis: profile = tester.analyze(ingredient, depth="comprehensive") else: profile = tester.analyze(ingredient, depth="basic")
Validate Results
# Check result validity if profile.is_valid(): # Proceed with analysis print(profile.get_summary()) else: print("Warning: Analysis may be incomplete")
Handle Edge Cases
# Handle special cases if ingredient.is_overripe(): print("Warning: Ingredient may affect taste analysis")
API Reference
Classes
TasteTester
: Main taste testing classTasteProfile
: Taste profile data classAromaProfile
: Aroma profile data classTextureProfile
: Texture profile data classQualityProfile
: Quality profile data classTasteVisualizer
: Visualization class
Methods
TasteTester 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)
Next Steps
Kitchen Hardware Interface - Control kitchen equipment
API Reference - Explore the full API
Tutorials - Learn advanced techniques
Last updated
Was this helpful?