diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..703d538 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: ".github/workflows" + schedule: + interval: "weekly" + groups: + actions: + patterns: + - "*" diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..a55cbf7 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,17 @@ +changelog: + exclude: + authors: + - pre-commit-ci + categories: + - title: Bug Fixes + labels: + - bug + - title: New Features + labels: + - enhancement + - title: Documentation + labels: + - Documentation + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 000b26f..6c3b8a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,15 +5,26 @@ on: pull_request: jobs: + test: uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 with: envs: | - linux: codestyle - pytest: false - linux: py38-test-oldestdeps - macos: py39-test - windows: py39-test - linux: py310-test - - linux: py311-test-devdeps + - macos: py311-test + - windows: py312-test + - linux: py313-test-devdeps coverage: 'codecov' + + publish: + needs: test + uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1 + with: + test_extras: test + test_command: pytest --pyargs astrodendro + secrets: + pypi_token: ${{ secrets.pypi_token }} diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml new file mode 100644 index 0000000..7347b6e --- /dev/null +++ b/.github/workflows/update-changelog.yaml @@ -0,0 +1,33 @@ +# This workflow takes the GitHub release notes an 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@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@61ce794778aa787ea8d204d9fe2928543cb2fe40 # v1.11.0 + 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@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGES.md diff --git a/CHANGES b/CHANGES.md similarity index 73% rename from CHANGES rename to CHANGES.md index b08cd01..96c37be 100644 --- a/CHANGES +++ b/CHANGES.md @@ -1,21 +1,12 @@ -0.3.0 (unreleased) ------------------- +## 0.2.0 (2016-09-29) -- Updated package infrastructure. [#186] +- Make sure that calling structure_at with an array, list, or tuple all behave the same. [#98] -0.2.0 (2016-09-29) ------------------- - -- Make sure that calling structure_at with an array, list, or tuple all - behave the same. [#98] - -- Added support for linked scatter plots and multiple selections. - [#104, #105, #109, #136] +- Added support for linked scatter plots and multiple selections. [#104, #105, #109, #136] - Added support for custom functions to define what a 'neighbor' is. [#108] -- Fixed a bug that caused the interactive viewer when showing a dendrogram - loaded from a file. [#106, #110] +- Fixed a bug that caused the interactive viewer when showing a dendrogram loaded from a file. [#106, #110] - Added a 'prune' method to prune dendrograms after computing them. [#111] @@ -23,8 +14,7 @@ - Cache/memoize catalog statistics. [#115] -- Make sure that periodic boundaries (e.g. longitude) are properly - supported. [#121] +- Make sure that periodic boundaries (e.g. longitude) are properly supported. [#121] - Added progress bar for catalog computation. [#127] @@ -36,7 +26,6 @@ - Give HDUs names in FITS output. [#144] -0.1.0 (2013-11-09) ------------------- +## 0.1.0 (2013-11-09) Initial release diff --git a/astrodendro/analysis.py b/astrodendro/analysis.py index 350505f..1f4e78c 100644 --- a/astrodendro/analysis.py +++ b/astrodendro/analysis.py @@ -639,7 +639,7 @@ def _make_catalog(structures, fields, metadata, statistic, verbose=False): for index_array, shape in zip(indices, shape_tuple): # catch simple cases where a structure wraps around the image boundary i2 = np.where(index_array < shape/2, index_array+shape, index_array) - if i2.ptp() < index_array.ptp(): # more compact with wrapping. Use this + if np.ptp(i2) < np.ptp(index_array): # more compact with wrapping. Use this index_array[:] = i2 stat = ScalarStatistic(values, indices) diff --git a/astrodendro/dendrogram.py b/astrodendro/dendrogram.py index 63e36ad..6493fe1 100644 --- a/astrodendro/dendrogram.py +++ b/astrodendro/dendrogram.py @@ -625,6 +625,10 @@ def __init__(self, dendrogram): uniq, bins = np.unique(index_map, return_inverse=True) packed = dict((u, i) for i, u in enumerate(uniq)) + # starting with numpy 2.0 or later, bins is no longer 1-dimensional, + # so we always ravel the array to make it 1-d + bins = bins.ravel() + flat_idx = index_map.ravel() ri = np.argsort(bins) idx_ct = np.bincount(bins) diff --git a/astrodendro/viewer.py b/astrodendro/viewer.py index 2c5b608..49822a3 100644 --- a/astrodendro/viewer.py +++ b/astrodendro/viewer.py @@ -1,7 +1,6 @@ # Licensed under an MIT open source license - see LICENSE from collections import defaultdict -import warnings from functools import reduce import numpy as np diff --git a/pyproject.toml b/pyproject.toml index 7e7daea..a26b75d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,98 @@ [build-system] +build-backend = "setuptools.build_meta" -requires = ["setuptools", - "setuptools_scm", - "wheel"] +requires = [ + "setuptools>=61.2", + "setuptools-scm", +] -build-backend = 'setuptools.build_meta' +[project] +name = "astrodendro" +description = "Python package for computation of astronomical dendrograms" +readme.content-type = "text/markdown" +readme.file = "README.md" +license.text = "MIT" +authors = [ + { name = "Thomas Robitaille", email = "thomas.robitaille@gmail.com" }, + { name = "Chris Beaumont" }, + { name = "Adam Ginsburg" }, + { name = "Braden MacDonald" }, + { name = "and Erik Rosolowsky" }, +] +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3" +] +dynamic = [ + "version", +] +dependencies = [ + "astropy>=5", + "h5py>=3", + "matplotlib>=3.3", + "numpy>=1.20", +] + +[project.optional-dependencies] +docs = [ + "aplpy", + "numpydoc", + "sphinx<7", + "sphinx-astropy", +] +test = [ + "pytest", + "pytest-cov", +] + +[project.urls] +homepage = "https://www.dendrograms.org/" +documentation = "https://dendrograms.readthedocs.io/en/stable/" +repository = "https://github.com/dendrograms/astrodendro" + +[tool.setuptools] +zip-safe = false +license-files = [ + "LICENSE", +] +include-package-data = false + +[tool.setuptools.packages.find] +namespaces = false + +[tool.setuptools.package-data] +"astrodendro.tests" = [ + "*.npz", + "benchmark_data/*.fits", +] +"astrodendro.io.tests" = [ + "data/*", +] + +[tool.setuptools_scm] +write_to = "astrodendro/version.py" + +[tool.coverage.run] +omit = [ + "astrodendro/conftest.py", + "astrodendro/tests/*", + "astrodendro/*/tests/*", + "astrodendro/extern/*", + "astrodendro/version*", + "*/astrodendro/conftest.py", + "*/astrodendro/tests/*", + "*/astrodendro/*/tests/*", + "*/astrodendro/extern/*", + "*/astrodendro/version*", +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "except ImportError", + "raise AssertionError", + "raise NotImplementedError", + "def main\\(.*\\):", + "pragma: py{ignore_python_version}", + "def _ipython_key_completions_", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4636d14..0000000 --- a/setup.cfg +++ /dev/null @@ -1,66 +0,0 @@ -[metadata] -name = astrodendro -author = Thomas Robitaille, Chris Beaumont, Adam Ginsburg, Braden MacDonald, and Erik Rosolowsky -author_email = thomas.robitaille@gmail.com -license = MIT -license_file = LICENSE -url = http://www.dendrograms.org -description = Python package for computation of astronomical dendrograms -long_description = file: README.md -long_description_content_type = text/markdown -edit_on_github = False -github_project = dendrograms/astrodendro - -[options] -zip_safe = False -packages = find: -python_requires = >=3.8 -setup_requires = setuptools_scm -install_requires = - numpy>=1.20 - astropy>=5.0 - matplotlib>=3.3 - h5py>=3 - -[options.extras_require] -test = - pytest - pytest-cov -docs = - sphinx<7 - numpydoc - sphinx-astropy - aplpy - -[options.package_data] -astrodendro.tests = *.npz, benchmark_data/*.fits -astrodendro.io.tests = data/* - -[coverage:run] -omit = - astrodendro/conftest.py - astrodendro/tests/* - astrodendro/*/tests/* - astrodendro/extern/* - astrodendro/version* - */astrodendro/conftest.py - */astrodendro/tests/* - */astrodendro/*/tests/* - */astrodendro/extern/* - */astrodendro/version* - -[coverage:report] -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - # Don't complain about packages we have installed - except ImportError - # Don't complain if tests don't hit assertions - raise AssertionError - raise NotImplementedError - # Don't complain about script hooks - def main\(.*\): - # Ignore branches that don't pertain to this version of Python - pragma: py{ignore_python_version} - # Don't complain about IPython completion helper - def _ipython_key_completions_ diff --git a/setup.py b/setup.py deleted file mode 100755 index 4368a5f..0000000 --- a/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python - -import os - -from setuptools import setup - -VERSION_TEMPLATE = """ -# Note that we need to fall back to the hard-coded version if either -# setuptools_scm can't be imported or setuptools_scm can't determine the -# version, so we catch the generic 'Exception'. -try: - from setuptools_scm import get_version - version = get_version(root='..', relative_to=__file__) -except Exception: - version = '{version}' -""".lstrip() - -setup(use_scm_version={'write_to': os.path.join('astrodendro', 'version.py'), - 'write_to_template': VERSION_TEMPLATE}) diff --git a/tox.ini b/tox.ini index 3298357..c344359 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ deps = oldestdeps: h5py==3.0.* oldestdeps: matplotlib==3.3.* oldestdeps: numpy==1.20.* + oldestdeps: pillow==8.0.* extras = test