Message415593
An important point nobody made, as far as I can see:
* the main usability improvement justifying math.isclose is that you don't know the order of magnitude of your correct value--it could be anything (even infinite), and the manner of comparison depends on it. That's why it uses a sensible rel_tol out of the box, but no abs_tol--obviously, since it doesn't want to give nonsense results for e.g. values close to zero.
* but when you write tests, you always know the exact value you should get, right? In almost all cases the second argument is a numeric literal. So the delta-approach is perfectly ok in that context, since you're in control of how much discrepancy you're going to tolerate, and in the moment that you're deciding on this, you have the exact value expected right in front of you. |
|
Date |
User |
Action |
Args |
2022-03-20 05:26:54 | veky | set | recipients:
+ veky, rhettinger, gregory.p.smith, mark.dickinson, rbcollins, ezio.melotti, r.david.murray, michael.foord, berker.peksag, Pam.McANulty, ChrisBarker, iritkatriel |
2022-03-20 05:26:54 | veky | set | messageid: <1647754014.83.0.989157960228.issue27198@roundup.psfhosted.org> |
2022-03-20 05:26:54 | veky | link | issue27198 messages |
2022-03-20 05:26:54 | veky | create | |
|