Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions .github/workflows/mmtwfs-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ jobs:
pytest: false
- linux: py313-alldeps-cov
name: py313
- linux: py313-astropydev
name: py313-astropy-latest
continue-on-error: true
- linux: py313-numpydev
name: py313-numpy-latest
- linux: py313-devdeps
name: py313-devdeps
continue-on-error: true
- linux: build_docs
coverage: 'codecov'
Expand Down
37 changes: 19 additions & 18 deletions mmtwfs/tests/test_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
WFS_DATA_DIR = importlib.resources.files("mmtwfs") / "data"


def _analyze_image(wfs, test_file):
results = wfs.measure_slopes(test_file)
zresults = wfs.fit_wavefront(results)
plt.close("all")
return zresults


def test_check_wfsdata():
try:
check_wfsdata("bogus.fits")
Expand Down Expand Up @@ -74,11 +81,10 @@ def test_make_mask():
assert mask.min() == 0.0


def test_mmirs_analysis():
def test_mmirs_analysis(benchmark):
test_file = WFS_DATA_DIR / "test_data" / "mmirs_wfs_0150.fits"
mmirs = WFSFactory(wfs="mmirs")
results = mmirs.measure_slopes(test_file)
zresults = mmirs.fit_wavefront(results)
zresults = benchmark(_analyze_image, mmirs, test_file)
testval = int(zresults["zernike"]["Z10"].value)
assert (testval > 416) & (testval < 436)
plt.close("all")
Expand Down Expand Up @@ -133,51 +139,46 @@ def test_mmirs_bogus_pupil_mask():
assert False


def test_f9_analysis():
def test_f9_analysis(benchmark):
test_file = WFS_DATA_DIR / "test_data" / "TREX_p500_0000.fits"
f9 = WFSFactory(wfs="f9")
results = f9.measure_slopes(test_file)
zresults = f9.fit_wavefront(results)
zresults = benchmark(_analyze_image, f9, test_file)
testval = int(zresults["zernike"]["Z09"].value)
assert (testval > 440) & (testval < 450)
plt.close("all")


def test_newf9_analysis():
def test_newf9_analysis(benchmark):
test_file = WFS_DATA_DIR / "test_data" / "test_newf9.fits"
f9 = WFSFactory(wfs="newf9")
results = f9.measure_slopes(test_file)
zresults = f9.fit_wavefront(results)
zresults = benchmark(_analyze_image, f9, test_file)
testval = int(zresults["zernike"]["Z09"].value)
assert (testval > 109) & (testval < 129)
plt.close("all")


def test_f5_analysis():
def test_f5_analysis(benchmark):
test_file = WFS_DATA_DIR / "test_data" / "auto_wfs_0037_ave.fits"
f5 = WFSFactory(wfs="f5")
results = f5.measure_slopes(test_file)
zresults = f5.fit_wavefront(results)
zresults = benchmark(_analyze_image, f5, test_file)
testval = int(zresults["zernike"]["Z10"].value)
assert (testval > 76) & (testval < 96)
plt.close("all")


def test_bino_analysis():
def test_bino_analysis(benchmark):
test_file = WFS_DATA_DIR / "test_data" / "wfs_ff_cal_img_2017.1113.111402.fits"
wfs = WFSFactory(wfs="binospec")
results = wfs.measure_slopes(test_file, mode="binospec")
zresults = wfs.fit_wavefront(results)
zresults = benchmark(_analyze_image, wfs, test_file)
testval = int(zresults["zernike"]["Z10"].value)
assert (testval > 163) & (testval < 183)
plt.close("all")


def test_flwo_analysis():
def test_flwo_analysis(benchmark):
test_file = WFS_DATA_DIR / "test_data" / "1195.star.p2m18.fits"
wfs = WFSFactory(wfs="flwo15")
results = wfs.measure_slopes(test_file)
zresults = wfs.fit_wavefront(results)
zresults = benchmark(_analyze_image, wfs, test_file)
testval = int(zresults["zernike"]["Z06"].value)
assert (testval > 700) & (testval < 1000)
plt.close("all")
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ test = [
"pytest-astropy",
"black",
"flake8",
"coverage"
"coverage",
"pytest-benchmark",
]
docs = [
"sphinx-astropy",
Expand Down Expand Up @@ -78,7 +79,7 @@ testpaths = [
"mmtwfs/tests",
"docs",
]
astropy_header = true
astropy_header = false
doctest_plus = "enabled"
text_file_format = "rst"
addopts = [
Expand Down
18 changes: 12 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
envlist =
py{312,313}{,-alldeps}{,-cov}
py{312,313}-{numpy,astropy}dev
py{312,313}{,-alldeps,-devdeps}{,-cov}
build_docs
linkcheck
codestyle
Expand All @@ -17,9 +16,13 @@ usedevelop = False
# Pass through the following environemnt variables which may be needed for the CI
passenv = HOME,WINDIR,LC_ALL,LC_CTYPE,CC,CI

# Set variable to point to the nightly wheels for dev dependencies
setenv =
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/liberfa/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple

# Run the tests in a temporary directory to make sure that we don't import
# astropy from the source tree
changedir = {toxworkdir}/tox_testing
changedir = .tmp/{envname}

# tox environments are constructued with so-called 'factors' (or terms)
# separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor:
Expand All @@ -33,12 +36,15 @@ description =
run tests
cov: with coverage enabled
alldeps: with all optional dependencies
{numpy,astropy}dev: with latest master from github repo
devdeps: with nightly wheels of cores dependencies
cov_report: generate HTML coverage report

deps =
numpydev: git+https://github.com/numpy/numpy.git#egg=numpy
astropydev: git+https://github.com/astropy/astropy.git#egg=astropy
devdeps: numpy>=0.0.dev0
devdeps: astropy>=0.0.dev0
devdeps: scipy>=0.0.dev0
devdeps: matplotlib>=0.0.dev0
devdeps: scikit-image>=0.0.dev0

# need to have run tests before making coverage report
depends =
Expand Down