Doctest failure in 'What's new in 5.0?'
See original GitHub issueI tried enabling doctests in the 5.0 What’s New to make sure all the examples work fine and ran into the following failure:
=================================== FAILURES ===================================
______________________________ [doctest] 5.0.rst _______________________________
091 (and enabled by default) to allow for redshift - dimensionless conversions.
092 To convert between redshift and other cosmological distance measures, e.g.
093 CMB temperature or comoving distance, the equivalency ``with_redshift`` is
094 also added.
095
096 >>> import astropy.units as u
097 >>> import astropy.cosmology.units as cu
098 >>> z = 1100 * cu.redshift
099
100 >>> z.to(u.dimensionless_unscaled)
UNEXPECTED EXCEPTION: UnitConversionError("'redshift' and '' (dimensionless) are not convertible")
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest 5.0.rst[11]>", line 1, in <module>
File "/home/runner/work/astropy/astropy/.tox/py39-test-cov/lib/python3.9/site-packages/astropy/units/quantity.py", line 849, in to
value = self._to_value(unit, equivalencies)
File "/home/runner/work/astropy/astropy/.tox/py39-test-cov/lib/python3.9/site-packages/astropy/units/quantity.py", line 803, in _to_value
return self.unit.to(unit, self.view(np.ndarray),
File "/home/runner/work/astropy/astropy/.tox/py39-test-cov/lib/python3.9/site-packages/astropy/units/core.py", line 1135, in to
return self._get_converter(Unit(other),
File "/home/runner/work/astropy/astropy/.tox/py39-test-cov/lib/python3.9/site-packages/astropy/units/core.py", line 1066, in _get_converter
raise exc
File "/home/runner/work/astropy/astropy/.tox/py39-test-cov/lib/python3.9/site-packages/astropy/units/core.py", line 1051, in _get_converter
return self._apply_equivalencies(
File "/home/runner/work/astropy/astropy/.tox/py39-test-cov/lib/python3.9/site-packages/astropy/units/core.py", line 1027, in _apply_equivalencies
raise UnitConversionError(
astropy.units.core.UnitConversionError: 'redshift' and '' (dimensionless) are not convertible
/home/runner/work/astropy/astropy/docs/whatsnew/5.0.rst:100: UnexpectedException
If the example is incorrect, it should be fixed in the v5.0.x branch directly. Otherwise, what could be going wrong?
See https://github.com/astropy/astropy/runs/4081948989?check_suite_focus=true for the full log
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Doctest returning failure, yet "Expected" and "Got" match ...
I already saw one question here that asked "How can python 2 doctest fail and yet have no difference in values in the...
Read more >doctest — Test interactive Python examples — Python 3.11.1 ...
This section examines in detail how doctest works: which docstrings it looks at, how it finds interactive examples, what execution context it uses,...
Read more >Python's doctest: Document and Test Your Code at Once
In a doctest test, a blank line means that the code you just executed doesn't issue any output. That's why the output of...
Read more >doctest – Testing through documentation - PyMOTW
doctest lets you test your code by running examples embedded in the documentation and verifying that they produce the expected results.
Read more >ExUnit.DocTest — ExUnit v1.15.0-dev - HexDocs
Every new test starts on a new line, with an iex> prefix. ... If you try to match on such an expression, doctest...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mhvk @nstarman - would one of you have time to open a PR to fix this? Thanks!
@mhvk @nstarman the issue is the following example at the end of
equivalencies.rst
in the docs:Note that if I remove this, there is another failure in the what’s new which is due to the fact scipy should be defined as a doctest-requires dependency.
@mhvk - how do you suggest we fix the equivalencies example? It’s probably not good practice to set equivalencies globally, right? (especially if it removes other build-in ones)