Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 1.1.1 (2026-11-21)
## 1.1.1 (2026-11-22)

A patch release: three fixes for noise and side effects met when `hyp.plot`
draws into a figure the caller built, found by executing notebooks with
Expand Down Expand Up @@ -75,12 +75,31 @@ draws into a figure the caller built, found by executing notebooks with
same glyphs are still reached through 'Hiragino Sans'); a font named with
`font=`, and a font found to be the only one covering the text, are kept
regardless.

- **A Yahoo Finance rate limit is reported as one.** When Yahoo throttles
an address it answers HTTP 429 with a plain-text body, which
`hyp.load('yahoo:<TICKER>')` reported as "returned a non-JSON response
(HTTP 429) ... JSONDecodeError". The error now says that Yahoo is
rate-limiting the address and to try again later.
- **A seeded UMAP no longer warns about `n_jobs`.** umap-learn runs
single-threaded whenever it is seeded and says so with "n_jobs value 1
overridden to 1 by setting random_state". hypertools already kept that
warning away for the top-level `random_state=`; a seed passed in the
`reduce` dict (`reduce={'model': 'UMAP', 'kwargs': {'random_state':
0}}`, as several gallery examples do) still drew it. Both forms are now
quiet and give the same embedding. A call that sets `n_jobs` itself
still gets umap's warning.

### Documentation

- **Two gallery examples are now seeded.** The k-means panel of
`plot_colorbar.py` and the UMAP panel of `plot_digits.py` came out
different on every docs build (cluster colors permuted; a different UMAP
layout). Both now pass `random_state=0`, so every gallery figure that
does not read live data is the same from build to build.
- **`plot_shapes_zoo.py`: no stray axis labels.** The biplane is the one
shape that loads as a DataFrame (columns `x`, `y`, `z`), so its panel
alone carried axis labels, one of them out in the grid's empty cell. The
example now passes empty labels.

### Documented limitations

Expand Down
4 changes: 2 additions & 2 deletions docs/prebuilt_gallery.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commit": "c90dd87e32e545ad17d12f2568993fbd0fc55f24",
"source_commit": "514a12cb72269baca147a12d8c4cd8a783e4dd54",
"commit": "598c4d87cd56c0e02d45b7282716381458673ab9",
"source_commit": "12e98347ace2fedd241a1d1623799eeee03ae648",
"version": "1.1.1"
}
4 changes: 3 additions & 1 deletion examples/plot_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# Discrete groups (here, k-means clusters) get a segmented colorbar with
# one tick/block per group instead of a continuous gradient. A dict lets
# you set a label or move the colorbar to another side of the figure.
# (k-means starts from random centers; ``random_state`` keeps the cluster
# numbering, and so the colors, the same from run to run.)

hyp.plot(data, '.', n_clusters=4,
hyp.plot(data, '.', n_clusters=4, random_state=0,
colorbar={'label': 'cluster', 'location': 'right'})
5 changes: 4 additions & 1 deletion examples/plot_digits.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@

# %%
# ... and with UMAP, which is faster and keeps more of the global layout.
hyp.plot(data, '.', reduce='UMAP', hue=hue, ndims=2, legend=True)
# UMAP's layout is random unless it is seeded; ``random_state`` makes the
# figure the same on every run.
hyp.plot(data, '.', reduce='UMAP', random_state=0, hue=hue, ndims=2,
legend=True)
6 changes: 5 additions & 1 deletion examples/plot_shapes_zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
# fits each panel's own reduction separately, exactly as the equivalent
# per-panel hyp.plot(shape, ax=ax) loop did, since these clouds differ
# enough in scale that one shared fit would be dominated by the largest.
# The biplane loads as a DataFrame with columns x, y and z, which hypertools
# would write beside that one panel as axis labels; the empty labels keep
# all seven panels alike.
hyp.plot([hyp.load(shape) for shape in shapes], ',', color='k',
panels=(2, 4), panel_fit='independent',
title=[shape.capitalize() for shape in shapes], size=(12, 6))
title=[shape.capitalize() for shape in shapes], size=(12, 6),
xlabel='', ylabel='', zlabel='')
32 changes: 24 additions & 8 deletions hypertools/reduce/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ def reduce(x, reduce='IncrementalPCA', ndims=None, return_model=False,
and inspect.isclass(c_model)
and 'random_state' in inspect.signature(c_model).parameters):
c_kwargs['random_state'] = random_state
# a seeded UMAP runs single-threaded and warns "n_jobs value
# ... overridden to 1"; whoever set the seed (the user in
# 'kwargs', or the top-level random_state just injected) did
# not choose n_jobs, so pass the value umap will use anyway
# (see the same step for the bare-name form below)
if (inspect.isclass(c_model)
and getattr(c_model, '__name__', '') == 'UMAP'
and c_kwargs.get('random_state') is not None
and 'n_jobs' not in c_kwargs and len(c_args) == 0
and 'n_jobs' in inspect.signature(c_model).parameters):
c_kwargs['n_jobs'] = 1
# construct immediately; the resulting instance flows through
# the same already-constructed-instance handling below as a
# bare instance passed directly as `reduce=`. An ALREADY-
Expand Down Expand Up @@ -484,14 +495,19 @@ def reduce(x, reduce='IncrementalPCA', ndims=None, return_model=False,
and 'random_state' not in model_params
and 'random_state' in inspect.signature(model).parameters):
model_params['random_state'] = random_state
# umap-learn forces n_jobs=1 whenever a random_state is set and
# warns that it did ("n_jobs value -1 overridden to 1 ..."), which
# would blame the user for a seed hypertools injected. Pass the
# n_jobs umap is going to use anyway, unless the user chose one.
if (getattr(model, '__name__', '') == 'UMAP'
and 'n_jobs' not in model_params
and 'n_jobs' in inspect.signature(model).parameters):
model_params['n_jobs'] = 1

# umap-learn forces n_jobs=1 whenever a random_state is set and warns
# that it did ("n_jobs value -1 overridden to 1 ..."). The user asked
# for a seed (top-level `random_state=`, or in the `reduce` dict's
# kwargs), not for a number of jobs, so the warning tells them nothing
# they chose: pass the n_jobs umap is going to use anyway. A user who
# set n_jobs themselves still gets umap's warning about it.
if (not model_is_instance
and getattr(model, '__name__', '') == 'UMAP'
and model_params.get('random_state') is not None
and 'n_jobs' not in model_params
and 'n_jobs' in inspect.signature(model).parameters):
model_params['n_jobs'] = 1

# sklearn TSNE's default perplexity (30) requires n_samples > 30, so
# small datasets crashed on a parameter the user never set
Expand Down
42 changes: 42 additions & 0 deletions notes/release_notes_v1.1.1_draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# HyperTools 1.1.1

A patch release with no API changes. It fixes noise and side effects met when `hyp.plot` draws into a figure the caller built (`ax=`), found by executing notebooks with `jupyter nbconvert` under matplotlib 3.11, and one misleading error message from the Yahoo Finance loader.

Every change is listed in the [changelog](https://github.com/ContextLab/hypertools/blob/v1.1.1/CHANGELOG.md); these notes summarize it.

## Install

```bash
pip install --upgrade hypertools
```

Python 3.10 through 3.13. Extras are unchanged from 1.1.0.

## Fixed

- **The backend warning is issued once, and only when it applies ([#290](https://github.com/ContextLab/hypertools/issues/290)).** When hypertools cannot set up an interactive matplotlib backend at import (for example in a notebook kernel without `ipympl`), `hyp.plot` repeated the warning on every call, including static plots and calls that show no live figure. It is now issued only by a call that displays an animated or interactive plot that matplotlib renders, and once per session per message.
- **`hyp.plot(..., ax=ax)` leaves the layout of the caller's figure alone ([#291](https://github.com/ContextLab/hypertools/issues/291)).** Static plots ended with `plt.tight_layout()` even when the caller passed its own axes, which moved every axes of the figure, discarded `subplots_adjust` margins, replaced a `layout='constrained'` engine, and acted on pyplot's current figure rather than the one that owns `ax`. A figure the caller built is now left as the caller arranged it. Figures hypertools makes itself (its own figure, a `panels=` grid, a `hyp.subplots` grid) are laid out as before.
- **A legend or title added to the caller's axes is fitted automatically, inside that axes' own room.** Through 1.1.0 a `legend=` beside a caller's axes was fitted by widening the caller's figure, which stretched its other axes and switched off its layout engine. Now, when the figure is drawn, only the axes passed as `ax=` is narrowed just far enough that its legend ends before the canvas edge or the next panel, and lowered just far enough that its title stays on the canvas. No call is needed, and the fit follows a later `fig.tight_layout()`, `fig.subplots_adjust(...)`, resize or save. A legend with no room beside the axes is drawn inside it; one too large for its panel either way is left in place with a `UserWarning` naming the remedies.
- **No `findfont` log lines for ordinary text under matplotlib 3.11 ([#292](https://github.com/ContextLab/hypertools/issues/292)).** matplotlib 3.11 logs a line each time a family in the font list has no face at a text's exact weight; one of the fallback families hypertools listed has no regular face on macOS, so every figure logged the line several times. Fallback families with no regular-weight face are now left out of the list.
- **A Yahoo Finance rate limit is reported as one.** `hyp.load('yahoo:<TICKER>')` reported an HTTP 429 from Yahoo as a JSON decoding failure. The error now says that Yahoo is rate-limiting the address and to try again later.
- **A seeded UMAP no longer warns about `n_jobs`.** A seed passed in the `reduce` dict (`reduce={'model': 'UMAP', 'kwargs': {'random_state': 0}}`) drew umap-learn's "n_jobs value 1 overridden to 1" warning; it is now quiet, like the top-level `random_state=`.

## Documentation

- Two gallery examples (`plot_colorbar.py`, `plot_digits.py`) are now seeded, so their figures are the same on every docs build, and `plot_shapes_zoo.py` no longer shows stray axis labels beside one panel.

## Upgrading from 1.1.0

- **If you relied on the automatic `tight_layout`** of a figure made with `plt.subplots`, call `fig.tight_layout()` after plotting, create the figure with `layout='constrained'`, or build the grid with `hyp.subplots`.
- On an axes whose legend or title was fitted, `ax.get_position()` reports the position of the last draw (the fit is an axes locator, recomputed on each draw).

## Known limitations

- The automatic fit does not detect an inset or other axes placed by hand where the legend goes, or a legend over the tick labels of its own axes' twin.
- Bold or other non-regular text can still log `findfont` lines under matplotlib 3.11 when an installed fallback family ships a regular face only; see "Documented limitations" in the changelog.

## Links

- Documentation: https://hypertools.readthedocs.io/en/stable/
- Changelog: https://github.com/ContextLab/hypertools/blob/v1.1.1/CHANGELOG.md
- PyPI: https://pypi.org/project/hypertools/1.1.1/
115 changes: 115 additions & 0 deletions notes/session_2026-11-21_release-1.1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,118 @@ pass on matplotlib 3.10.8 and 3.11.2.
- Sphinx `-b html -W -E -a` with every gallery example re-executed, at
49165c09: build succeeded.
- `ruff check`: all checks passed.

## Gallery rebuild and before/after review (2026-11-21, late evening)

Request: rebuild the gallery, review before/after for ALL figures (own review
plus an independent one, ideally Codex), and build a draft release. Working
unattended; the user is on a phone.

- PR #294 (automatic legend/title fit) merged as e3abb840 with all CI green.
- Built the gallery in release form from e3abb840 (51 of 51 examples
executed, sphinx exit 0, 32 min). Compared it with two baselines using
a scratch script (pixel statistics on every PNG, every GIF frame, every
MP4 frame, plotly payload hashes): the published 1.1.0 gallery
(`docs-gallery-v1.1.0`, 519b4af2) and the pre-fit 1.1.1 gallery (built
from 514a12cb).
- Result: 89 figures + 51 thumbnails. 87 of 89 byte-identical to the
pre-fit build; 85 of 89 to 1.1.0. The differences:
- `plot_colorbar_002.png`: k-means unseeded, cluster colors permuted on
every build (same points). Not from the code change.
- `plot_digits_003.png`: UMAP unseeded, new layout every build.
- `animate_market_sectors_001.gif/.mp4` (vs 1.1.0 only): live Yahoo data,
one more month (ends October 31, 2026 instead of September 30, 2026).
- No gallery example puts a legend on an axes the example made itself (five
use `ax=`, with titles only, which already fit), so the fit changing no
gallery figure is expected. My earlier guess that four examples would
render differently was wrong.
- Fix: both examples now pass `random_state=0` (the library's own argument;
passing UMAP's `random_state` through the `reduce` dict works too but
prints umap's n_jobs warning). Verified: two runs each give identical
figures, no warnings with `-W error::UserWarning`.
- Release form: README images flipped to `v1.1.1` (13 URLs), tutorial
install cells already correct (migrator: 76 of 76). NOTE: the migrator
must run on the `master` branch; on any other branch it retargets the
tutorials to that branch.
- Plan: commit on local `master` (not pushed to `master`; pushed as
`release/1.1.1` so nothing on `master` changes before the user's go),
rebuild the gallery from that commit, repeat the comparison, independent
review (Codex + fresh subagent), publish the pre-built gallery (keeping
the old commit c90dd87e reachable on a `docs-gallery-v1.1.1-prev` branch
because `master`'s docs build fetches it by id), record it, publish the
notebooks, build wheel + sdist, create a DRAFT GitHub release (no tag).
Tag, PyPI and the `master` push wait for the user's go.
- Found while running the examples gate: `animate_painting_embeddings.py`
and `animate_conversation.py` seed UMAP through the `reduce` dict, which
drew umap's "n_jobs value 1 overridden to 1 by setting random_state"
warning (not shown on the docs pages, but shown to anyone running the
example). Fixed in `hypertools/reduce/reduce.py`: the dict form now passes
`n_jobs=1` when the model is seeded and the caller named no `n_jobs`
(same as the bare-name form already did). Regression test in
`tests/test_reduce_third_party_warnings.py`; changelog entry. The first
gallery build from the release commit was stopped for this and restarted.
- Own review of all 89 figures (contact sheets, 117 tiles: every still,
middle and last frame of every animation): everything matches 1.1.0
apart from the three explained cases. One defect that 1.1.0 has too:
`plot_shapes_zoo_001.png` showed stray x/y/z axis labels beside the
Biplane panel (the biplane loads as a DataFrame, the other six shapes as
arrays; column names become axis labels by design). Example now passes
`xlabel='', ylabel='', zlabel=''`. Second gallery build stopped and
restarted for this.
- Observed, left as is (faithful rendering of raw data, same as 1.1.0):
in `plot_datasets_tour_001.png` the penguins and Kaggle-iris panels are
near-lines because one unnormalized column dominates.

### 2026-11-22 (after midnight)

- Independent reviews of all 117 tiles (fresh subagent; Codex CLI with the
ten contact sheets attached): no regression from 1.1.0; the three
differing figures judged harmless; both flagged the shapes-zoo labels
(fixed). Minor points they raised that are IDENTICAL in the released
1.1.0 and were left for the user to decide: conversation clip's box
touches the left canvas edge; teapot is faint under the one-pixel
marker; two label boxes overlap in `plot_labels`; market-sectors legend
sits close to the box in the GIF thumbnail; weather clip's last marker is
half clipped at the right edge.
- Third build (from a7dfad3a, 51 of 51 executed): 136 of 140 media files
byte-identical to the reviewed e3abb840 build; the four that differ are
the three changed examples (colorbar_002, digits_003, shapes_zoo_001 and
its thumbnail). Viewed all three: correct.
- Page-text diff against 1.1.0 (versions and timings normalized) found one
environment artifact: `plot_datasets_tour` printed kagglehub's "outdated
version (installed: 1.0.2)" notice. Upgraded kagglehub in the build venv
to 1.0.3.
- The date rolled over during the build. The release gate requires the
CHANGELOG heading not to be earlier than the release commit, and the
gallery record commit would be dated 2026-11-22, so the heading is now
2026-11-22 and the gallery is rebuilt once more from this commit (the
gate allows only the record commit after the build).
- Issue #295 (animate= with panels=, per-frame caption, +faststart) was
filed 2026-11-22 from the timecorr work. It is a feature request, not in
this build; whether it goes into 1.1.1 is the user's decision.

### Release commit, first cut (d743ff5d) and its CI

- Fourth build (from 46c3bb39): all 140 media files byte-identical to the
third, no kagglehub notice. Full suite on 46c3bb39: 6910 passed, 24
skipped, 0 failed. Rehearsal: REHEARSAL PASSED (full).
- Published `docs-gallery-v1.1.1` (2cf4fd0d), recorded it (d743ff5d),
pushed as `release/1.1.1` (PR #296), published `docs-notebooks/v1.1.1/`.
All 25 release gates passed locally and in a depth-1 clone with only
pytest, nbformat and nbclient installed. Built wheel + sdist, smoke
tested, created the DRAFT GitHub release (no tag).
- The user looked at the review page
(https://claude.ai/artifact/W1YfFGsWHoKsxh3ofWgmuj): "Updated gallery
looks good; changes all go in the right direction".
- CI on d743ff5d: 14 jobs green, `test (windows-latest, 3.11)` failed in
`tests/plot/test_predict_animation.py::test_the_plotly_backend_DRAWS_the_same_case_the_same_way`:
it asserts no warnings at all, and on that runner two Kalman fits took
0.5 s, so hypertools' own "needs 8 forecast fits ... roughly 12.8 s"
notice fired. Machine-speed dependent, nothing to do with this change.
Fix: that test and its matplotlib twin pass `slow_warning_seconds=None`,
as `tests/plot/test_forecast_schedule.py` does.
- A new commit invalidates everything pinned to d743ff5d, so the gallery is
rebuilt from the new commit and both galleries, the dist files and the
draft release's assets are redone.
- Gap in the automatic "work in flight" check: it did not see the running
`wait-for-ci.py` waiter and asked for another.
Loading
Loading