{"record":{"id":"3a0ca8229070584b","repo":"TheAlgorithms/Python","slug":"all-parameters-must-be-positive","errorCode":null,"errorMessage":"All parameters must be positive.","messagePattern":"All parameters must be positive\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"physics/rainfall_intensity.py","lineNumber":133,"sourceCode":"    Traceback (most recent call last):\n    ...\n    ValueError: All parameters must be positive.\n\n    >>> rainfall_intensity(1000, 0.2, 11.6, 0.81, 10, 0)\n    Traceback (most recent call last):\n    ...\n    ValueError: All parameters must be positive.\n\n    \"\"\"\n    if (\n        coefficient_k <= 0\n        or coefficient_a <= 0\n        or coefficient_b <= 0\n        or coefficient_c <= 0\n        or return_period <= 0\n        or duration <= 0\n    ):\n        raise ValueError(\"All parameters must be positive.\")\n    intensity = (coefficient_k * (return_period**coefficient_a)) / (\n        (duration + coefficient_b) ** coefficient_c\n    )\n    return intensity\n\n\nif __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n","sourceCodeStart":115,"sourceCodeEnd":144,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/physics/rainfall_intensity.py#L115-L144","documentation":"Raised by the intensity function in physics/rainfall_intensity.py when any of coefficient_k, coefficient_a, coefficient_b, coefficient_c, return_period, or duration is <= 0. The empirical IDF (intensity-duration-frequency) formula i = k*T^a / (duration + b)^c requires all six parameters strictly positive; the single shared message does not identify which parameter failed.","triggerScenarios":"intensity(k=0, a=0.2, b=10, c=0.8, return_period=5, duration=60); any call where duration=0 (common when testing instantaneous intensity) or return_period=0; negative regional regression coefficients from a malformed IDF table.","commonSituations":"Loading IDF coefficients from regional tables where some entries are 0 or blank-parsed-as-0; passing duration in the wrong unit that truncates to 0; mixing up argument order so a duration lands in return_period.","solutions":["Check each of the six values is > 0 before the call; log all offenders since the error message does not name one","Verify the IDF coefficient table for the region (k, a, b, c must all be positive from the regression source)","Pass duration >= 1 minute (in whatever unit the coefficients were fitted with), never 0","Confirm argument order matches the function signature when porting formulas from literature"],"exampleFix":"# before\nintensity(0, 0.2, 10, 0.8, 5, 60)  # k=0 slips through from an empty table cell\n# ValueError: All parameters must be positive.\n\n# after\nparams = {'k': 32.5, 'a': 0.2, 'b': 10, 'c': 0.8, 'return_period': 5, 'duration': 60}\nassert all(v > 0 for v in params.values()), params\nintensity(**params)","handlingStrategy":"validation","validationCode":"params = {\n    'coefficient_k': k, 'coefficient_a': a, 'coefficient_b': b,\n    'coefficient_c': c, 'return_period': T, 'duration': D,\n}\nbad = [name for name, v in params.items() if v <= 0]\nif bad:\n    raise ValueError(f\"non-positive IDF parameters: {bad}\")\nintensity(k, a, b, c, T, D)","typeGuard":null,"tryCatchPattern":"try:\n    i = intensity(k, a, b, c, T, D)\nexcept ValueError:\n    raise ValueError(f\"check IDF params k={k} a={a} b={b} c={c} T={T} D={D}\")","preventionTips":["Validate all six parameters yourself — the shared message does not name the offender","duration=0 is invalid; use the smallest unit your coefficients were fitted with (e.g. 1 minute)","Cross-check regional IDF coefficient tables for zero/empty entries"],"tags":["physics","hydrology","idf","validation","valueerror"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}