Opened 7 years ago

Closed 6 years ago

#677 closed defect (fixed)

add doctest option to check if result and expected result are numerically close

Reported by: mabshoff Owned by: mhansen
Priority: major Milestone: sage-2.8.15
Component: doctest coverage Keywords: doctest, numerical noise
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

[02:48] <mhansen_> Regarding testing with small numerical differences, that would still be something that'd need to be handled in within the doctest code since nose provides a "wrapper" around doctest.
[02:48] <mabshoff> ok
[02:48] <williamstein> The point would only be about what options there might be for doing it.
[02:49] <williamstein> It might still have to go via preparsing.
[02:49] <williamstein> E.g., a special comment
[02:49] <williamstein> sage: foo(2.1)      # random low order bits
[02:49] <williamstein> could mean that the output should be checked except the last 3 bits discarded
[02:49] <williamstein> Another possibility would be to rewrite the doctests like this:
[02:49] <williamstein> sage: foo(2.1)
[02:50] <williamstein> 1.239930820384...
[02:50] <williamstein> Then the doctest framework just ignored everythign starting at the ...'s.
[02:50] <williamstein> But everything before will be checked to make sure it is the same.
[02:50] <mabshoff> That sounds like a good solution with the "..."
[02:50] <williamstein> That actually might be a good approach, since it will work in more complicated cases:
[02:50] <williamstein> [foo(2.1), foo(2.2)]
[02:50] <williamstein> [1.20919..., 2.233....]
[02:50] <williamstein> You could try it with that doctest just now.

Change History (2)

comment:1 Changed 7 years ago by mabshoff

  • Component changed from packages to doctest

comment:2 Changed 6 years ago by mabshoff

  • Milestone changed from sage-2.9.1 to sage-2.8.15
  • Resolution set to fixed
  • Status changed from new to closed

Ok, this works in python's doctests, so no need to implement this. Maybe it still needs to be added to the manual.

Cheers,

Michael

Note: See TracTickets for help on using tickets.