Skip to content

Commit

Permalink
update CI & test
Browse files Browse the repository at this point in the history
  • Loading branch information
keyuxing committed Aug 12, 2023
1 parent 9734274 commit 6e9feee
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install --without dev
poetry install
- name: Run tests
run: |
Expand Down
66 changes: 53 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ python = ">=3.8"

[tool.poetry.group.dev.dependencies]
black = ">=23.3.0"
parameterized = ">=0.9.0"
ruff = ">=0.0.284"

[tool.black]
line-length = 120
Expand Down
50 changes: 35 additions & 15 deletions tests/test_plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,55 @@

import lightkurve as lk
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from parameterized import parameterized_class

from tpfi import plot_identification, plot_season
from tpfi import plot_identification, plot_season, plot_sky, plot_tpf

OUTPUT_DIR = Path("test_output")
OUTPUT_DIR.mkdir(exist_ok=True)


class TestPlotFunctions(unittest.TestCase):
@parameterized_class(
[
{"target": "TIC150428135", "search_params": {"sector": 1, "exptime": 120, "author": "SPOC"}},
{"target": "KIC1161345", "search_params": {"quarter": 17, "exptime": 1800}},
{"target": "EPIC211765471", "search_params": {"campaign": 5, "exptime": 1800}},
]
)
class TestIdentificationFunctions(unittest.TestCase):
def setUp(self):
warnings.simplefilter("ignore", ResourceWarning)
self.tpf = lk.search_targetpixelfile(self.target, **self.search_params).download()

def test_plot_identification_tess(self):
tpf = lk.search_targetpixelfile("TIC150428135", sector=1, exptime=120, author="SPOC").download()
plot_identification(tpf)
plt.savefig(OUTPUT_DIR / "test_tess_identification.png", bbox_inches="tight")
def tearDown(self):
plt.close("all")

def test_plot_identification_kepler(self):
tpf = lk.search_targetpixelfile("KIC1161345", quarter=17, exptime=1800).download()
plot_identification(tpf)
plt.savefig(OUTPUT_DIR / "test_kepler_identification.png", bbox_inches="tight")
def test_plot_sky(self):
plot_sky(self.tpf)
plt.savefig(OUTPUT_DIR / f"test_sky_{self.tpf.mission}.png", bbox_inches="tight", dpi=300)

def test_plot_identification_k2(self):
tpf = lk.search_targetpixelfile("EPIC211765471", campaign=5, exptime=1800).download()
plot_identification(tpf)
plt.savefig(OUTPUT_DIR / "test_k2_identification.png", bbox_inches="tight")
def test_plot_tpf(self):
plot_tpf(self.tpf)
plt.savefig(OUTPUT_DIR / f"test_tpf_{self.tpf.mission}.png", bbox_inches="tight", dpi=300)

def test_plot_tpf_with_cbar(self):
_, ax = plt.subplots(figsize=(6, 4))
divider = make_axes_locatable(ax)
ax_cb = divider.append_axes("right", size="15%", pad=0.1)

plot_tpf(self.tpf, ax=ax, ax_cb=ax_cb)
plt.savefig(OUTPUT_DIR / f"test_tpf_with_cbar_{self.tpf.mission}.png", bbox_inches="tight", dpi=300)

def test_plot_identification(self):
plot_identification(self.tpf)
plt.savefig(OUTPUT_DIR / f"test_identification_{self.tpf.mission}.png", bbox_inches="tight", dpi=300)


class TestSeasonFunction(unittest.TestCase):
def test_plot_season(self):
plot_season("KIC10139564")
plt.savefig(OUTPUT_DIR / "test_season.png", bbox_inches="tight")
plt.savefig(OUTPUT_DIR / "test_season.png", bbox_inches="tight", dpi=300)


if __name__ == "__main__":
Expand Down

0 comments on commit 6e9feee

Please sign in to comment.