Skip to content

Commit

Permalink
Merge pull request #120 from astrofrog/update-infrastructure
Browse files Browse the repository at this point in the history
Fix compatibility with latest version of astropy and update infrastructure
  • Loading branch information
astrofrog authored Nov 16, 2023
2 parents 0f61293 + 17a8371 commit c39eb1e
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 168 deletions.
21 changes: 21 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
changelog:
exclude:
authors:
- pre-commit-ci
labels:
- no-changelog-entry-needed
- skip-changelog

categories:
- title: New Features
labels:
- enhancement
- title: Bug Fixes
labels:
- bug
- title: Documentation
labels:
- documentation
- title: Other Changes
labels:
- "*"
75 changes: 27 additions & 48 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,32 @@
name: Run tests

on: [push, pull_request]
on:
push:
pull_request:

jobs:
tests:
name: ${{ matrix.name}}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: 3.9
name: Python 3.9 with minimal dependencies
toxenv: py39-test
- os: ubuntu-latest
python-version: 3.8
name: Python 3.8 with minimal dependencies
toxenv: py38-test
- os: ubuntu-latest
python-version: 3.7
name: Python 3.7 with minimal dependencies
toxenv: py37-test
- os: ubuntu-latest
python-version: 3.9
name: Python 3.9, all non-visualization dependencies, and dev versions of key dependencies
toxenv: py39-test-novis-dev
- os: windows-latest
python-version: 3.9
name: Python 3.9, all dependencies, and dev versions of key dependencies on Windows
toxenv: py39-test-all-dev
- os: ubuntu-latest
python-version: 3.9
name: Documentation
toxenv: build_docs

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install testing dependencies
run: python -m pip install tox codecov
- name: Run tests with ${{ matrix.name }}
if: ${{ contains(matrix.toxenv,'-cov') }}
run: tox -v -e ${{ matrix.toxenv }}
- name: Upload coverage to codecov
if: ${{ contains(matrix.toxenv,'-cov') }}
uses: codecov/[email protected]
with:
file: ./coverage.xml
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
display: true
libraries: |
apt:
- '^libxcb.*-dev'
- libxkbcommon-x11-dev
- libegl1-mesa
envs: |
- linux: py38-test-oldestdeps
- linux: py39-test
- linux: py310-test-viz
- linux: py311-test-alldeps
- linux: py312-test-devdeps
- macos: py38-test-oldestdeps
- macos: py39-test
- macos: py310-test-viz
- macos: py311-test-alldeps
- macos: py312-test-devdeps
- windows: py38-test-oldestdeps
- windows: py39-test
- windows: py310-test-viz
- windows: py311-test-alldeps
- windows: py312-test-devdeps
33 changes: 33 additions & 0 deletions .github/workflows/update-changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow takes the GitHub release notes and updates the changelog on the
# main branch with the body of the release notes, thereby keeping a log in
# the git repo of the changes.

name: "Update Changelog"

on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: main

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
release-notes: ${{ github.event.release.body }}
latest-version: ${{ github.event.release.name }}
path-to-changelog: CHANGES.md

- name: Commit updated Changelog
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: Update CHANGELOG
file_pattern: CHANGES.md
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ distribute-*.tar.gz

# Mac OSX
.DS_Store

.tmp
16 changes: 0 additions & 16 deletions CHANGES

This file was deleted.

23 changes: 23 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# v0.3 (2022-03-31)

## What's Changed

* Plot docs and convenience tools by @keflavich in https://github.com/radio-astro-tools/pvextractor/pull/102
* Add gh actions by @keflavich in https://github.com/radio-astro-tools/pvextractor/pull/103
* try to fix grid by removing 'novis' by @keflavich in https://github.com/radio-astro-tools/pvextractor/pull/105
* allow DaskSpectralCube, etc. to work by @keflavich in https://github.com/radio-astro-tools/pvextractor/pull/99

**Full Changelog**: https://github.com/radio-astro-tools/pvextractor/compare/v0.2...v0.3

# v0.2 (2020-04-19)

* Update package infrastructure. #93, #96
* Fix compatibility with the latest versions of Python and Matplotlib. #89, #95
* Added `return_area` option for `extract_poly_slices`. #59
* Fix error that occurred when WCS did not have a PC matrix defined. #90

# v0.1 (2018-01-26)

* First official release.


22 changes: 5 additions & 17 deletions pvextractor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""
This is an Astropy affiliated package.
"""

# Affiliated packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import *
# ----------------------------------------------------------------------------

if not _ASTROPY_SETUP_:

from . import utils
from .pvextractor import extract_pv_slice
from .utils.wcs_slicing import slice_wcs
from .geometry import Path, PathFromCenter
from .pvregions import paths_from_regfile
from . import utils
from .pvextractor import extract_pv_slice
from .utils.wcs_slicing import slice_wcs
from .geometry import Path, PathFromCenter
from .pvregions import paths_from_regfile
52 changes: 0 additions & 52 deletions pvextractor/_astropy_init.py

This file was deleted.

7 changes: 0 additions & 7 deletions pvextractor/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ def pytest_configure(config):
PYTEST_HEADER_MODULES['regions'] = 'regions'
PYTEST_HEADER_MODULES['APLpy'] = 'aplpy'


from astropy.tests.helper import enable_deprecations_as_exceptions

## Uncomment the following line to treat all DeprecationWarnings as
## exceptions
# enable_deprecations_as_exceptions()

app = None


Expand Down
53 changes: 38 additions & 15 deletions pvextractor/tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
from distutils.version import LooseVersion
from packaging.version import Version

import pytest
import numpy as np
import matplotlib
from matplotlib.backend_bases import KeyEvent, MouseEvent

from ..gui import PVSlicer

from .test_slicer import make_test_hdu
from .test_slicer import make_test_hdu, make_test_fits_file

MPL_LT_31 = LooseVersion(matplotlib.__version__) < LooseVersion('3.1')
MATPLOTLIB_GE_36 = Version(matplotlib.__version__) >= Version('3.6')

def key_press_event(canvas, *event):
if MATPLOTLIB_GE_36:
canvas.callbacks.process('key_press_event',
KeyEvent('key_press_event', canvas, *event))
else:
canvas.key_press_event(*event)


def button_press_event(canvas, *event):
if MATPLOTLIB_GE_36:
canvas.callbacks.process('button_press_event',
MouseEvent('button_press_event', canvas, *event))
else:
canvas.button_press_event(*event)


def motion_notify_event(canvas, *event):
if MATPLOTLIB_GE_36:
canvas.callbacks.process('motion_notify_event',
MouseEvent('motion_notify_event', canvas, *event))
else:
canvas.motion_notify_event(*event)


def test_gui():

# This tests currently segfaults with Matplotlib 3.1 and later
pytest.importorskip('PyQt6')

hdu = make_test_hdu()

pv = PVSlicer(hdu, clim=(-0.02, 2), backend='Qt5Agg')
pv = PVSlicer(hdu, clim=(-0.02, 2), backend='QtAgg')
pv.show(block=False)

xy_data = np.array([[0.0, 0.1, 0.5, 1.0, 0.5],
Expand All @@ -26,12 +50,12 @@ def test_gui():
x, y = pv.ax1.transData.transform(xy_data).T

for i in range(len(x)):
pv.fig.canvas.motion_notify_event(x[i], y[i])
pv.fig.canvas.button_press_event(x[i], y[i], 1)
motion_notify_event(pv.fig.canvas, x[i], y[i])
button_press_event(pv.fig.canvas, x[i], y[i], 1)

pv.fig.canvas.key_press_event('enter')
pv.fig.canvas.motion_notify_event(x[-1] - 20, y[-1])
pv.fig.canvas.button_press_event(x[-1] - 20, y[-1], 1)
key_press_event(pv.fig.canvas, 'enter')
motion_notify_event(pv.fig.canvas, x[-1] - 20, y[-1])
button_press_event(pv.fig.canvas, x[-1] - 20, y[-1], 1)

pv.fig.canvas.draw()

Expand All @@ -40,14 +64,13 @@ def test_gui():
pv.close()


def test_gui_from_fits_filename():
def test_gui_from_fits_filename(tmp_path):

# This tests currently segfaults with Matplotlib 3.1 and later
pytest.importorskip('PyQt6')

fits_filename = make_test_fits_file()
fits_filename = make_test_fits_file(tmp_path)

pv = PVSlicer(fits_filename, clim=(-0.02, 2), backend='Qt5Agg')
pv = PVSlicer(fits_filename, clim=(-0.02, 2), backend='QtAgg')
pv.show(block=False)

pv.close()

4 changes: 2 additions & 2 deletions pvextractor/tests/test_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def make_test_hdu():
return hdu


def make_test_fits_file():
def make_test_fits_file(tmp_path):
hdu = make_test_hdu()
filename = 'example.fits'
filename = tmp_path / 'example.fits'
hdu.writeto(filename)
return filename

Expand Down
Loading

0 comments on commit c39eb1e

Please sign in to comment.