{"id":23905,"library":"iteround","title":"iteround","description":"A Python library for rounding iterables (lists, arrays, sets, etc.) while preserving the total sum of the original values. Version 1.0.4 is stable with no recent updates; maintained on GitHub.","status":"active","version":"1.0.4","language":"python","source_language":"en","source_url":"https://github.com/cgdeboer/iteround","tags":["rounding","iterable","sum-preserving","safe-round"],"install":[{"cmd":"pip install iteround","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"This is the primary function for rounding an iterable while preserving sum.","symbol":"safe_round","correct":"from iteround import safe_round"}],"quickstart":{"code":"from iteround import safe_round\n\nvalues = [1.5, 2.5, 3.5]\nrounded = safe_round(values, places=0)\nprint(rounded)\n# Output: [2, 2, 4] (sum remains 7, same as original)","lang":"python","description":"Round each element while maintaining the sum of the original iterable."},"warnings":[{"fix":"Use `from iteround import safe_round`.","message":"The function name is `safe_round`, not `iteround` or `round_iterable`. Using a wrong import will cause NameError.","severity":"gotcha","affected_versions":"all"},{"fix":"Understand that `safe_round` trades off per-element rounding accuracy for total sum preservation.","message":"The rounding algorithm adjusts some values to preserve the sum, so individual values may not round naively. This is intentional but can be surprising if you expect standard rounding.","severity":"gotcha","affected_versions":"all"},{"fix":"Always pass `topline` as a keyword argument to avoid breakage if the parameter order changes.","message":"The `topline` parameter in `safe_round` was added in 1.0.3 but may be renamed in future versions. Check the documentation for the latest signature.","severity":"deprecated","affected_versions":"1.0.3+"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from iteround import safe_round` then call `safe_round(...)`.","cause":"Attempting to call `iteround(...)` directly without importing the function.","error":"NameError: name 'iteround' is not defined"},{"fix":"Use `safe_round(values, places=2)` instead of `safe_round(values, precision=2)`.","cause":"Using the wrong parameter name; the correct parameter is `places` not `precision`.","error":"TypeError: safe_round() got an unexpected keyword argument 'precision'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}