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

local testing error in test_new_observatories.py #1304

Closed
scottransom opened this issue Jun 24, 2022 · 3 comments · Fixed by #1305
Closed

local testing error in test_new_observatories.py #1304

scottransom opened this issue Jun 24, 2022 · 3 comments · Fixed by #1305

Comments

@scottransom
Copy link
Member

This is with latest numpy, scipy, astropy, and python 3.10.4 and with the new tagged v 0.9.0:

 pytest tests/test_new_observatories.py                                          12:59:19
================================== test session starts ===================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/sransom/git/PINT
plugins: cov-3.0.0, xdist-2.5.0, anyio-3.5.0, forked-1.4.0, hypothesis-6.45.3, typeguard-2.13.3
collected 1 item                                                                         

tests/test_new_observatories.py F                                                  [100%]

======================================== FAILURES ========================================
_____________________________________ test_get_TOAs ______________________________________

    @pytest.mark.skipif(
        "TEMPO2" not in os.environ,
        reason="Needs TEMPO2 clock files, but TEMPO2 envariable not set",
    )
    def test_get_TOAs():
        tt = get_TOAs(StringIO(tim), ephem="DE421")
        # Check the site clock correction by itself
        site = get_observatory("meerkat", include_gps=False, include_bipm=False)
        clock_corr = site.clock_corrections(tt.table["mjd"][0])
>       assert np.isclose(clock_corr.value, 0.40802)  # from mk2utc.clk
E       assert False
E        +  where False = <function isclose at 0x7fb2f2990700>(0.4095630000003458, 0.40802)
E        +    where <function isclose at 0x7fb2f2990700> = np.isclose
E        +    and   0.4095630000003458 = <Quantity 0.409563 us>.value

tests/test_new_observatories.py:30: AssertionError
@aarchiba
Copy link
Contributor

Ah this is happening because the test assumes if your $TEMPO2 is set then that's where it finds a specific version of the MeerKAT clock corrections. (Incidentally the test's use of .value is a bug because some clock corrections are stored in seconds and some in microseconds, with appropriate units attached.) But I think that this is reporting that the current MeerKAT clock corrections for the first MJD in that file don't agree with the version that was in the TEMPO2 repository at the time the test was written.

I haven't actually done a direct comparison of the observatory-provided clock corrections with what is in the TEMPO2 repository yet; the repository provides both, appropriately labelled. This test is failing because PR #1302 switched to using the observatory clock corrections. When I have time I'll take a closer look and see if I can turn this test into one that produces diagnosable failures. But resolving the difference between MeerKAT clock files may require a response from Ryan Shannon.

@paulray
Copy link
Member

paulray commented Jun 24, 2022

I think the actual problem is that the test assumes you are using mk2utc.clk but PR #1302 makes PINT use mk2observatory.clk, which is slightly different. The test will not get run if you don't have TEMPO2 set, so you won't see this issue, but it is not related to the clk files in the TEMPO2 repo.
So, we should remove the code that skips this test if TEMPO2 is not set, and fix the test to test what we really want to test.

@aarchiba
Copy link
Contributor

These tests that check for a specific numerical value, it's often very difficult to figure out what it is supposed to be testing. But yes, in this case, the problem (?) is the difference between the official observatory-released clock corrections and the clock corrections in the TEMPO2 repository.

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 a pull request may close this issue.

3 participants