Skip to content

Commit

Permalink
Merge pull request #200 from astrofrog/update-infrastructure
Browse files Browse the repository at this point in the history
Update infrastructure and fix compatibility with Numpy 2.0
  • Loading branch information
astrofrog authored Nov 15, 2024
2 parents 67b972f + 33ef70f commit 28002dd
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 110 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: ".github/workflows"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
17 changes: 17 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -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:
- "*"
15 changes: 13 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
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 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
23 changes: 6 additions & 17 deletions CHANGES → CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
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]

- Added support for brightness temperatures in Kelvin. [#112]

- 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]

Expand All @@ -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
2 changes: 1 addition & 1 deletion astrodendro/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions astrodendro/dendrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion astrodendro/viewer.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
99 changes: 95 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
{ 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_",
]
66 changes: 0 additions & 66 deletions setup.cfg

This file was deleted.

19 changes: 0 additions & 19 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ deps =
oldestdeps: h5py==3.0.*
oldestdeps: matplotlib==3.3.*
oldestdeps: numpy==1.20.*
oldestdeps: pillow==8.0.*

extras =
test
Expand Down

0 comments on commit 28002dd

Please sign in to comment.