Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize most doctests with Pint's current behavior #1116

Merged
merged 7 commits into from
Jun 17, 2020

Conversation

clarkgwillison
Copy link
Contributor

  • Closes # (no single issue)
  • Executed black -t py36 . && isort -rc . && flake8 with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

This PR partially addresses #947, #972, and #990

After merging, the number of failing doctests in the Sphinx documentation should go from 92 (as mentioned in #947) down to 3:

Doctest summary
===============
  335 tests
    3 failures in tests
    0 failures in setup code
    0 failures in cleanup code
build finished with problems.
make: *** [doctest] Error 1

Which will put us well in reach of enabling doctests in Travis to prevent documentation regressions in the future.

Most tests were fixed in this PR by deferring to the current behavior of Pint, however Quantity.__repr__() was modified to round floating point magnitudes to 9 digits to avoid several test failures that were being caused by floating point ambiguities.

Issue #1115 was opened to track the 3 tests that I could not easily resolve. Once that issue is resolved, we can enable doctests in Travis without breaking CI.

rounding after 9 digits will make doctests more stable and less
prone to subtle floating point errors whenever they reference
a magnitude's repr()

repr() for ints and numpy array magnitudes unchanged
doctests updated for new 9-digit Quantity().__repr__()

added dependency on Serialize to requirements_docs.txt

in systems.rst: three errors remain, one may be a regression,
the others I'm not qualified to comment on

in nonmult.rst: some issues around floating point estimation are made
more robust by using print()

seems like Quantity().__repr__() changed since these
tests were written, and could benefit from some floating-point
truncation

in pitheorem.rst the only error was dictionary ordering, which
is now deterministic in python3.7, but may still cause
issues down the line

no doctests in getting.rst, marked all as code blocks
now the example runs correctly under doctests
@clarkgwillison clarkgwillison changed the title Harmonize doctests with Pint's current behavior Harmonize most doctests with Pint's current behavior Jun 17, 2020
@clarkgwillison
Copy link
Contributor Author

@hgrecco this is ready for review

@hgrecco
Copy link
Owner

hgrecco commented Jun 17, 2020

This is awesome!

@hgrecco
Copy link
Owner

hgrecco commented Jun 17, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 17, 2020

Build succeeded:

@bors bors bot merged commit 4959f0f into hgrecco:master Jun 17, 2020
@clarkgwillison
Copy link
Contributor Author

This PR also resolved #1101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants