Skip to content

Adopt ginga 7.1's public set_hash API in the stretch adapter - #229

Open
mwcraig wants to merge 2 commits into
astropy:mainfrom
mwcraig:ginga-colordist-set-hash
Open

Adopt ginga 7.1's public set_hash API in the stretch adapter#229
mwcraig wants to merge 2 commits into
astropy:mainfrom
mwcraig:ginga-colordist-set-hash

Conversation

@mwcraig

@mwcraig mwcraig commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #226. The upstream issue we reported, ejeschke/ginga#1148, was fixed on ginga master (7.1.0.dev17): ginga now provides a public set_hash(base) helper as the supported way for ColorDist subclasses to install their normalized 0..1 curve, plus a build-time backward-compat shim in check_hash() that rescues old-contract integer hashes with a PendingDeprecationWarning.

This PR updates our compatibility code to track that resolution:

  • _AstropyStretchDist.calc_hash now installs the curve through the public set_hash() on ginga >= 7.1 instead of assigning self.hash directly; the integer-levels branch is kept for released ginga (<= 7.0), with a TODO to drop it once we require ginga >= 7.1.
  • The contract probe (here and in the tests) is now hasattr(ColorDist.ColorDistBase, "set_hash") rather than sniffing the hash dtype of a throwaway LinearDist.
  • New regression test asserting the adapter never triggers ginga's deprecation shim.
  • Adds the changelog entry that Support ginga master's normalized-float ColorDist hash contract #226 was missing, folded with this change.

We cannot remove the dual-contract code yet: released ginga still requires the integer-levels representation and has no set_hash, and pyproject.toml allows ginga>=3.4.

Testing

  • pixi run test against ginga 7.0.0: 236 passed, 2 skipped (legacy branch).
  • Venv with ginga master 7.1.0.dev17 (includes the #1148 fix): all 111 ginga tests pass with -W error::PendingDeprecationWarning, confirming set_hash() is used and the compat shim never fires.

Co-written with Claude Fable 5

https://claude.ai/code/session_019GuBhnNvskTtCsb6Pw69BC

mwcraig added 2 commits July 28, 2026 09:07
Upstream fixed ejeschke/ginga#1148 by adding a public set_hash()
helper for ColorDist subclasses and a backward-compat shim in
check_hash() that rescues old-contract integer hashes with a
PendingDeprecationWarning.

Probe for the new contract via hasattr(ColorDistBase, 'set_hash')
instead of sniffing the hash dtype of a throwaway LinearDist, and add a
regression test asserting the adapter never triggers ginga's
deprecation shim.

Co-written with Claude Fable 5

Claude-Session: https://claude.ai/code/session_019GuBhnNvskTtCsb6Pw69BC
On ginga >= 7.1 install the normalized 0..1 curve through the public
set_hash() helper added in the fix for ejeschke/ginga#1148 instead of
assigning self.hash directly. The legacy integer-levels branch stays
until astrowidgets requires ginga >= 7.1; released ginga (<= 7.0) has
no set_hash and uses the hash directly as color indices.

Also add the missing changelog entry for astropy#226.

Co-written with Claude Fable 5

Claude-Session: https://claude.ai/code/session_019GuBhnNvskTtCsb6Pw69BC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant