DEV Community

Open Question Brief
Open Question Brief

Posted on Edited on

Finding a mismatched ingredient weight before comparing two recipe trials

Two samples can have different tasting notes even when the recipe matches. A comparison tool should expect those notes to differ. The fields to check first are the ones that were supposed to stay the same.

Take the illustrative R-14 pastry trial: candidates A and B, 6 grams of matcha in each, one recipe version, the same operator, and the same bake-and-chill schedule. The original example does not name the operator or the date. The “same session” markers here describe that example; a live system would need actual identifiers recorded at the bench.

conditions = {
    "recipe_version": "R-14",
    "matcha_grams": 6,
    "operator_ref": "same operator",
    "session_ref": "same day",
    "bake_chill": "same 24-hour schedule",
}
a = {**conditions, "candidate": "A"}
b = {**conditions, "candidate": "B"}

def compare_conditions(left, right):
    if not left.get("candidate") or not right.get("candidate"):
        raise ValueError("Both candidate references are required")
    if left["candidate"] == right["candidate"]:
        raise ValueError("Use a continuity check for the same candidate")
    return [
        field for field in conditions
        if left.get(field) in (None, "") or right.get(field) in (None, "")
        or left[field] != right[field]
    ]

assert compare_conditions(a, b) == []
assert compare_conditions(a, {**b, "matcha_grams": 8}) == ["matcha_grams"]
assert compare_conditions(a, {**b, "operator_ref": None}) == ["operator_ref"]
Enter fullscreen mode Exit fullscreen mode

Six grams against eight returns the field that needs attention. A blank operator also stops the comparison, even if both rows have the same blank. The function checks whether the paired conditions are documented consistently. It does not select a winning sample. Keep colour, aroma and bitterness in separate observation fields and record them during the trial. If the purchasing team later wants to compare one candidate with its own previous batch, that is a different comparison.

By Jiang Rong Hao

Top comments (0)