Sampling error in tests
See original GitHub issue🐞 Problem
I have recently started to get a weird error after running pytest.
Traceback
============================================================================== FAILURES ==============================================================================
___________________________________________ test_sample_closed_starts_and_ends_at_min_anomaly_if_in_range_and_no_max_given ___________________________________________
> ???
tests/tests_twobody/test_sampling.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/tests_twobody/test_sampling.py:68: in test_sample_closed_starts_and_ends_at_min_anomaly_if_in_range_and_no_max_given
assert_quantity_allclose(result[-1], min_nu, atol=1e-14 * u.rad)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = <Quantity -3.99680289e-15 rad>, desired = <Quantity 6.2781633e-15 rad>, rtol = 1e-07, atol = <Quantity 1.e-14 rad>, kwargs = {}
np = <module 'numpy' from '/home/yash/poli_astro/poli/lib/python3.8/site-packages/numpy/__init__.py'>
_unquantify_allclose_arguments = <function _unquantify_allclose_arguments at 0x7f9a4d2caaf0>
def assert_quantity_allclose(actual, desired, rtol=1.e-7, atol=None,
**kwargs):
"""
Raise an assertion if two objects are not equal up to desired tolerance.
This is a :class:`~astropy.units.Quantity`-aware version of
:func:`numpy.testing.assert_allclose`.
"""
import numpy as np
from astropy.units.quantity import _unquantify_allclose_arguments
> np.testing.assert_allclose(*_unquantify_allclose_arguments(
actual, desired, rtol, atol), **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-14
E
E Mismatched elements: 1 / 1 (100%)
E Max absolute difference: 1.02749662e-14
E Max relative difference: 1.63661977
E x: array(-3.996803e-15)
E y: array(6.278163e-15)
../poli/lib/python3.8/site-packages/astropy/tests/helper.py:491: AssertionError
----------------------------------------------------------------------------- Hypothesis -----------------------------------------------------------------------------
Falsifying example: test_sample_closed_starts_and_ends_at_min_anomaly_if_in_range_and_no_max_given(
min_nu=<Quantity 6.2781633e-15 rad>, ecc=<Quantity 0.99161489>,
)
Ouput of pip freeze:
alabaster==0.7.12
anyio==2.0.2
apipkg==1.5
appdirs==1.4.4
argon2-cffi==20.1.0
astroid==2.4.2
astropy==4.2
astropy-sphinx-theme==1.1
astroquery==0.4.1
async-generator==1.10
attrs==20.3.0
Babel==2.9.0
backcall==0.2.0
beautifulsoup4==4.9.3
black==20.8b1
bleach==3.2.1
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
click==7.1.2
cognitive-complexity==1.2.0
colorama==0.4.4
confuse==1.4.0
coverage==5.3.1
cryptography==3.3.1
cycler==0.10.0
czml3==0.5.4
decorator==4.4.2
defusedxml==0.6.0
distlib==0.3.1
docutils==0.16
entrypoints==0.3
execnet==1.8.0
filelock==3.0.12
flake8==3.8.4
flake8-cognitive-complexity==0.1.0
flake8-polyfill==1.0.2
flit==3.0.0
flit-core==3.0.0
future==0.18.2
html5lib==1.1
htmlmin==0.1.12
hypothesis==6.0.1
idna==2.10
ImageHash==4.2.0
imagesize==1.2.0
iniconfig==1.1.1
ipykernel==5.4.3
ipython==7.19.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
isort==5.7.0
jedi==0.18.0
jeepney==0.6.0
Jinja2==2.11.2
joblib==1.0.0
jplephem==2.15
json5==0.9.5
jsonschema==3.2.0
jupyter-client==6.1.11
jupyter-core==4.7.0
jupyter-server==1.2.1
jupyterlab==3.0.4
jupyterlab-pygments==0.1.2
jupyterlab-server==2.1.2
jupyterlab-widgets==1.0.0
jupytext==1.9.1
keyring==21.8.0
kiwisolver==1.3.1
lazy-object-proxy==1.4.3
llvmlite==0.35.0
mando==0.6.4
markdown-it-py==0.6.1
MarkupSafe==1.1.1
matplotlib==3.3.3
mccabe==0.6.1
mdit-py-plugins==0.2.4
missingno==0.4.2
mistune==0.8.4
mypy==0.790
mypy-extensions==0.4.3
myst-parser==0.13.3
nbclassic==0.2.6
nbclient==0.5.1
nbconvert==6.0.7
nbformat==5.0.8
nbsphinx==0.8.0
nest-asyncio==1.4.3
networkx==2.5
nodejs==0.1.1
notebook==6.1.6
NotFound==1.0.2
npm==0.1.1
numba==0.52.0
numpy==1.20.0
numpydoc==1.1.0
optional-django==0.1.0
packaging==20.8
pandas==1.2.0
pandoc==1.0.2
pandocfilters==1.4.3
parso==0.8.1
pathspec==0.8.1
patsy==0.5.1
pexpect==4.8.0
phik==0.11.0
pickleshare==0.7.5
Pillow==8.1.0
plotly==4.14.3
plotly-express==0.4.1
pluggy==0.13.1
ply==3.11
poliastro==0.15.dev0
prometheus-client==0.9.0
prompt-toolkit==3.0.10
ptyprocess==0.7.0
py==1.10.0
pycodestyle==2.6.0
pycparser==2.20
pyerfa==1.7.1.1
pyflakes==2.2.0
Pygments==2.7.4
pyparsing==2.4.7
pyrsistent==0.17.3
pytest==6.2.2
pytest-cov==2.5.1
pytest-doctestplus==0.9.0
pytest-mpl==0.12
pytest-mypy==0.8.0
pytest-remotedata==0.3.2
python-dateutil==2.8.1
pytoml==0.1.21
pytz==2020.5
PyWavelets==1.1.1
PyYAML==5.3.1
pyzmq==20.0.0
radon==4.3.2
regex==2020.11.13
requests==2.25.1
retrying==1.3.3
scipy==1.6.0
seaborn==0.11.1
SecretStorage==3.3.0
Send2Trash==1.5.0
six==1.15.0
sniffio==1.2.0
snowballstemmer==2.0.0
sortedcontainers==2.3.0
soupsieve==2.1
Sphinx==3.4.3
sphinx-astropy==1.3
sphinx-autoapi==1.5.1
sphinx-automodapi==0.13
sphinx-gallery==0.8.2
sphinx-hoverxref==0.5b1
sphinx-notfound-page==0.6
sphinx-rtd-theme==0.5.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
statsmodels==0.12.1
tangled-up-in-unicode==0.0.6
Tcl==0.2
terminado==0.9.2
testpath==0.4.4
toml==0.10.2
tornado==6.1
tox==3.21.1
tqdm==4.56.0
traitlets==5.0.5
typed-ast==1.4.2
typing-extensions==3.7.4.3
Unidecode==1.1.2
urllib3==1.26.2
virtualenv==20.3.1
visions==0.6.0
w3lib==1.22.0
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
wrapt==1.12.1
📋 Steps to solve the problem Investigate tests, specifically focusing on what eccentricities are being used to test them.
Notes
- The error traceback clearly states that we use falsifying examples for testing. Specifically, the problem seems to be in the eccentricity used:
0.99161489(giving-3.996803e-15as the final true anomaly) where instead it must have used0.88680956which would have yielded a correct final true anomaly (6.278163e-15). See the test here - This mostly seems to be a problem in the testing part of the code and not in the source code implementation.
- I am currently investigating the cause and am not sure if this is only me or if it is really a bug.
Please let me know if this is really a problem.
Thanks!!
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (19 by maintainers)
Top Results From Across the Web
Sampling Error: Definition, Sources & Minimizing
Sampling error is the difference between a sample statistic and the population value it estimates, a crucial idea in inferential statistics.
Read more >Sampling Error - Voxco
Sampling error can be defined as a statistical error that occurs when a researcher fails to select a sample that is representative of...
Read more >How To Calculate Sampling Error in 6 Steps (With Examples)
A sampling error is a calculation that measures statistical error when a tester uses a sample that doesn't properly reflect the population under...
Read more >Time Sampling Error - Psychological Testing
Time sampling error refers to the variability inherent in test scores as a function of the fact that they are obtained at one...
Read more >Sampling Error Explained | CFA® Exam Study Notes
Sampling error is the statistical error that results when an analyst selects a sample that is not representative of the population as a...
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 Free
Top 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

Ok, I tried running the tests again, and now I do not get any errors!
numba -soutput:Oh wow, near-parabolic orbits there we go again… 😱
This is an excellent investigation, thanks for taking the time to dig into this. I’m so happy that we are using hypothesis to surface these sort of problems. Will give this some thought over the weekend, if anyone has more ideas feel free to share here.