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

Run tests in parallel #1798

Merged
merged 35 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ea598df
parallel tox
abhisrkckl Jul 2, 2024
37866df
pytest -p auto
abhisrkckl Jul 2, 2024
ae40390
-n
abhisrkckl Jul 2, 2024
2dbbf26
oldestdeps
abhisrkckl Jul 2, 2024
4d072d2
test_noisefit
abhisrkckl Jul 2, 2024
f0781b2
CHANGELOG
abhisrkckl Jul 2, 2024
fb3c6f1
test_publish
abhisrkckl Jul 2, 2024
a510a3c
test_timing_model
abhisrkckl Jul 2, 2024
8ed1af7
--
abhisrkckl Jul 2, 2024
e283c06
Merge branch 'master' into parallel-tox
abhisrkckl Jul 2, 2024
119b749
not verbose
abhisrkckl Jul 2, 2024
b830865
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Jul 11, 2024
7547985
Merge branch 'master' into parallel-tox
abhisrkckl Jul 12, 2024
237f665
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Jul 22, 2024
299bff5
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Jul 23, 2024
1a7fda3
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Aug 1, 2024
ab383b1
Merge branch 'master' into parallel-tox
abhisrkckl Aug 8, 2024
40382a4
Merge branch 'master' into parallel-tox
abhisrkckl Aug 11, 2024
8010f28
Merge branch 'master' into parallel-tox
abhisrkckl Aug 12, 2024
d13daab
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Aug 13, 2024
8bee2c6
rerun
abhisrkckl Aug 13, 2024
e6db751
CHANGELOG
abhisrkckl Aug 13, 2024
5580580
CHANGELOG
abhisrkckl Aug 13, 2024
b659ac4
oversubscribe
abhisrkckl Aug 13, 2024
0ca156d
test_toa_shuffle
abhisrkckl Aug 13, 2024
58438b8
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Aug 27, 2024
40c788a
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Aug 27, 2024
0eea13a
reduce nprocs for macos
abhisrkckl Aug 29, 2024
b65a136
tox.ini
abhisrkckl Aug 29, 2024
80111e4
verbose tests
abhisrkckl Aug 29, 2024
d0a8542
no parallel in macos
abhisrkckl Aug 29, 2024
87ffae3
refresh
abhisrkckl Aug 29, 2024
3e3bdfd
--
abhisrkckl Aug 29, 2024
4555fbe
ignore
abhisrkckl Aug 29, 2024
6b9af85
Merge branch 'nanograv:master' into parallel-tox
abhisrkckl Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ the released changes.
### Changed
- Moved the events -> TOAs and photon weights code into the function `load_events_weights` within `event_optimize`.
- Updated the `maxMJD` argument in `event_optimize` to default to the current mjd
- Run CI tests in parallel, re-run failed tests (for intermittent failures due to random chance)
- `maskParameter.__repr__()` output now includes the frozen attribute.
- Changed default value of `FDJUMPLOG` to `Y`
- Bumped `black` version to 24.x
Expand Down
2 changes: 2 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ wheel>=0.29.0
pytest>=4.3
pytest-cov>=2.7.1
pytest-runner>=5.1
pytest-xdist
pytest-rerunfailures
flake8>=3.7
pep8-naming>=0.8.2
flake8-docstrings>=1.4
Expand Down
55 changes: 36 additions & 19 deletions tests/test_noisefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,38 @@

from io import StringIO
import numpy as np
import pytest

par = """
ELAT 1.3 1
ELONG 2.5 1
F0 100 1
F1 1e-13 1
PEPOCH 55000
EPHEM DE440
EFAC mjd 50000 53000 2 1
EQUAD mjd 53000 55000 0.8 1
"""

m = get_model(StringIO(par))
t = make_fake_toas_uniform(50000, 55000, 200, m, add_noise=True)
@pytest.fixture
def model_and_toas_1():
par = """
ELAT 1.3 1
ELONG 2.5 1
F0 100 1
F1 1e-13 1
PEPOCH 55000
EPHEM DE440
EFAC mjd 50000 53000 2 1
EQUAD mjd 53000 55000 0.8 1
"""

m2, t2 = get_model_and_toas(
datadir / "ecorr_fit_test.par", datadir / "ecorr_fit_test.tim"
)
m = get_model(StringIO(par))
t = make_fake_toas_uniform(50000, 55000, 200, m, add_noise=True)

return m, t


@pytest.fixture
def model_and_toas_2():
return get_model_and_toas(
datadir / "ecorr_fit_test.par", datadir / "ecorr_fit_test.tim"
)


def test_white_noise_fit(model_and_toas_1):
m, t = model_and_toas_1

def test_white_noise_fit():
assert m.EFAC1.uncertainty_value == 0 and m.EQUAD1.uncertainty_value == 0

ftr = DownhillWLSFitter(t, m)
Expand All @@ -47,7 +58,9 @@ def test_white_noise_fit():
)


def test_white_noise_refit():
def test_white_noise_refit(model_and_toas_1):
m, t = model_and_toas_1

ftr = DownhillWLSFitter(t, m)

ftr.model.EFAC1.value = 1.5
Expand All @@ -67,7 +80,9 @@ def test_white_noise_refit():
)


def test_ecorr_fit():
def test_ecorr_fit(model_and_toas_2):
m2, t2 = model_and_toas_2

ftr = DownhillGLSFitter(t2, m2)
ftr.fit_toas()

Expand All @@ -79,7 +94,9 @@ def test_ecorr_fit():
)


def test_ecorr_refit():
def test_ecorr_refit(model_and_toas_2):
m2, t2 = model_and_toas_2

ftr = DownhillGLSFitter(t2, m2)

ftr.model.ECORR1.value = 0.75
Expand Down
39 changes: 23 additions & 16 deletions tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,37 @@
from pint.scripts import pintpublish
import os

data_NGC6440E = get_model_and_toas(datadir / "NGC6440E.par", datadir / "NGC6440E.tim")

@pytest.fixture
def data_NGC6440E():
return get_model_and_toas(datadir / "NGC6440E.par", datadir / "NGC6440E.tim")

def test_NGC6440E():

@pytest.fixture
def data_J0613m0200_NANOGrav_9yv1():
return get_model_and_toas(
datadir / "J0613-0200_NANOGrav_9yv1.gls.par",
datadir / "J0613-0200_NANOGrav_9yv1.tim",
)


@pytest.fixture
def data_J1614m2230_NANOGrav_12yv3_wb():
return get_model_and_toas(
datadir / "J1614-2230_NANOGrav_12yv3.wb.gls.par",
datadir / "J1614-2230_NANOGrav_12yv3.wb.tim",
)


def test_NGC6440E(data_NGC6440E):
m, t = data_NGC6440E
output = publish(m, t)
assert "1748-2021E" in output
assert "DE421" in output


data_J0613m0200_NANOGrav_9yv1 = get_model_and_toas(
datadir / "J0613-0200_NANOGrav_9yv1.gls.par",
datadir / "J0613-0200_NANOGrav_9yv1.tim",
)


@pytest.mark.parametrize("full", [True, False])
def test_J0613m0200_NANOGrav_9yv1(full):
def test_J0613m0200_NANOGrav_9yv1(data_J0613m0200_NANOGrav_9yv1, full):
m, t = data_J0613m0200_NANOGrav_9yv1
output = publish(
m, t, include_dmx=full, include_fd=full, include_noise=full, include_jumps=full
Expand All @@ -39,14 +52,8 @@ def test_J0613m0200_NANOGrav_9yv1(full):
assert not full or "RNAMP" in output


data_J1614m2230_NANOGrav_12yv3_wb = get_model_and_toas(
datadir / "J1614-2230_NANOGrav_12yv3.wb.gls.par",
datadir / "J1614-2230_NANOGrav_12yv3.wb.tim",
)


@pytest.mark.parametrize("full", [True, False])
def test_J1614m2230_NANOGrav_12yv3_wb(full):
def test_J1614m2230_NANOGrav_12yv3_wb(data_J1614m2230_NANOGrav_12yv3_wb, full):
m, t = data_J1614m2230_NANOGrav_12yv3_wb
output = publish(
m, t, include_dmx=full, include_fd=full, include_noise=full, include_jumps=full
Expand Down
3 changes: 0 additions & 3 deletions tests/test_timing_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ def timfile_nojumps():
return get_TOAs(os.path.join(datadir, "NGC6440E.tim"))


len_timfile_nojumps = len(get_TOAs(os.path.join(datadir, "NGC6440E.tim")))


class TestModelBuilding:
def setup_method(self):
self.parfile = os.path.join(datadir, "J0437-4715.par")
Expand Down
30 changes: 12 additions & 18 deletions tests/test_toa_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,22 @@
import pint.residuals
from pint.models import get_model

shuffletoas = """FORMAT 1
test 1234.0 54321 0 pks
test2 888 59055 0 meerkat
test3 350 59000 0 gbt
"""


class TOAOrderSetup:
parfile = os.path.join(datadir, "NGC6440E.par")
model = get_model(parfile)
# fake a multi-telescope, multi-frequency data-set and make sure the results don't depend on TOA order
fakes = [
t = (
simulation.make_fake_toas_uniform(
55000, 55500, 30, model=model, freq=1400 * u.MHz, obs="ao"
),
simulation.make_fake_toas_uniform(
)
+ simulation.make_fake_toas_uniform(
55010, 55500, 40, model=model, freq=800 * u.MHz, obs="gbt"
),
simulation.make_fake_toas_uniform(
)
+ simulation.make_fake_toas_uniform(
55020, 55500, 50, model=model, freq=2000 * u.MHz, obs="@"
),
]
f = io.StringIO()
for t in fakes:
t.write_TOA_file(f)
f.seek(0)
t = toa.get_TOAs(f)
)
)
r = pint.residuals.Residuals(t, model, subtract_mean=False)

@classmethod
Expand Down Expand Up @@ -95,6 +84,11 @@ def test_resorting_toas_chi2_match(sortkey):


class TOALineOrderSetup:
shuffletoas = """FORMAT 1
test 1234.0 54321 0 pks
test2 888 59055 0 meerkat
test3 350 59000 0 gbt
"""
timfile = io.StringIO(shuffletoas)
t = toa.get_TOAs(timfile)
timfile.seek(0)
Expand Down
16 changes: 12 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ envlist =
skip_missing_interpreters = True

[tool:pytest]
# pytest docs seem to say that this section should be called just pytest, not tool:pytest; is it working?
# pytest docs seem to say that this section should be called just pytest,
# not tool:pytest; is it working?
testpaths = tests
addopts =
--cov-report=term-missing
Expand All @@ -33,6 +34,8 @@ passenv =

deps =
pytest
pytest-xdist
pytest-rerunfailures
cov: coverage
cov: pytest-cov
cov: pytest-remotedata
Expand All @@ -42,8 +45,9 @@ deps =
setuptools
commands =
pip freeze
!cov: pytest
cov: pytest -v --pyargs tests --cov=pint --cov-config={toxinidir}/.coveragerc {posargs}
!cov: pytest --reruns 5 --verbose tests/test_toa_selection.py
!cov: pytest -n 6 --reruns 5 --verbose --ignore=tests/test_toa_selection.py
cov: pytest -n 6 --reruns 5 --verbose --pyargs tests --cov=pint --cov-config={toxinidir}/.coveragerc {posargs}
cov: coverage xml -o {toxinidir}/coverage.xml

depends =
Expand All @@ -70,9 +74,13 @@ deps =
matplotlib==3.2.0
scipy==1.4.1
pytest
pytest-xdist
pytest-rerunfailures
coverage
hypothesis<=6.72.0
commands = {posargs:pytest}
commands =
pytest -n 6 --reruns 5 --verbose


[testenv:report]
skip_install = true
Expand Down
Loading