Skip to content

refactor: search hygiene and dead code (search-extensibility A0b) - #1672

Merged
Jammy2211 merged 7 commits into
mainfrom
feature/search-ext-a0b-hygiene
Oct 8, 2026
Merged

Jammy2211 merged 7 commits into
mainfrom
feature/search-ext-a0b-hygiene

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Phase A0b of the search-extensibility epic (PyAutoFit#1670): dead code out of the non-linear search layer, the latent bugs survey 01 §8 named, and the two repairs the A0a(i) conformance suite carried as strict xfails. Seven commits, the test-directory move last and move-only. Shipped under the human's 2026-10-08 --auto launch; tier judge, so merge is a human /prm.

  • Removed make_sneakier_pool, SneakierPool and its FunctionCache helpers (no users anywhere in the workspace), the unread NonLinearSearch.iterations, Zeus's unused discard/thin/chain; _log_process_state is one module function.
  • Drawer runs under NullPaths (timer guard) and honours its search_internal argument; Nautilus no longer mutates iterations_per_full_update; AbstractNest defaults number_of_cores=1.
  • Unknown constructor kwargs log a WARNING (never raise); samples_from falls back only on (FileNotFoundError, NotImplementedError) and logs it.
  • SearchUpdater.update converts samples once and passes them to visualize; Emcee computes autocorrelation once per conversion (unit test counts exactly one).
  • BlackJAXNUTS and SMC accept the inverse_mass_matrix kind strings their own search.json writes ("none" → None; "array"/"result" load but raise at fit time with a clear message). ROUND_TRIP_XFAIL deleted; golden identifiers unchanged (BlackJAXNUTS 2a6f5217…, SMC 3baa494f…).
  • Stale AbstractNest and apply_test_mode docstrings fixed.

Two things for the reviewer (the plan did not settle them; both are reversible by reverting one commit):

  1. SettingsSearch.search_dict keeps its shape: about 223 workspace and pipeline call sites splat it into af.Nautilus(...), so filtering use_jax_vmap there would have changed a public property. A new search_dict_for(search_cls) filters by signature instead. Splatting the plain search_dict into a non-Nautilus search now warns about use_jax_vmap; no call site does that today.
  2. Narrowing the samples_from except exposed that plot_start_point asked an empty Emcee backend for samples and relied on the swallowed AttributeError. The start-point visualisation now passes plot_search=False and outputs only the analysis visuals; at that point there were never samples to plot, so the output set for fresh runs is unchanged.

The new kwarg warning also caught real typos outside this repo, filed as a Mind follow-up: auto_correlations_settings= in autofit_workspace searches/mcmc.py and workspace_test Emcee.py/Zeus.py (settings silently ignored until now), nlive= to DynestyDynamic in searches/nest.py, and dynamic_delta/delta in test_autofit/graphical/hierarchical/test_optimise.py.

API Changes

Removed dead parallel helpers and the unread iterations attribute; added SettingsSearch.search_dict_for, updater.log_process_state, and optional arguments on SearchUpdater.visualize / Emcee.samples_info_from / Nautilus.iterations_from. Behaviour: unknown search kwargs warn; AttributeError inside samples_via_internal_from now propagates instead of silently falling back to samples.csv; AbstractNest.number_of_cores defaults to 1 (was None). No downstream library (PyAutoLens/PyAutoGalaxy/PyAutoArray/PyAutoCTI) references any removed symbol (grep over their packages is empty).
See full details below.

Test Plan

  • pytest test_autofit -x: 3073 passed, 2 skipped, 3 xfailed (only the three CONFIG_MUTATION_XFAIL cases, A3)
  • unittest-nojax emulated (meta_path finder hiding jax/jaxlib/blackjax/optax/prodigyopt): test_autofit/non_linear 915 passed, 37 skipped, 3 xfailed
  • autofit_workspace searches/{mcmc,nest,mle}.py and autofit_workspace_test searches/{Emcee,Zeus,DynestyStatic,Nautilus,LBFGS,Drawer}.py under PYAUTO_TEST_MODE=1: all exit 0
  • grep -rn make_sneakier_pool autofit/ empty; new test__fit_with_default_null_paths fails on main, passes here
  • CI green on unittest 3.12 / 3.13 / nojax and docs
Full API Changes (for automation & release notes)

Removed

  • NonLinearSearch.make_sneakier_pool — no callers
  • autofit.non_linear.parallel.SneakierPool (and from parallel/__init__), parallel/sneaky.py FunctionCache, initializer, fitness_cache, prior_transform_cache — only used by the removed pool
  • NonLinearSearch.iterations — never read; SearchUpdater owns _iterations
  • NonLinearSearch._log_process_state, SearchUpdater._log_process_state — replaced by updater.log_process_state()

Added

  • autofit.non_linear.search.updater.log_process_state()
  • SettingsSearch.search_dict_for(search_cls) — settings filtered to what search_cls.__init__ accepts
  • NonLinearSearch._known_kwargs — kwargs never reported as unknown (save_all_samples, initial_values, inplace)
  • autofit.non_linear.search.mcmc.blackjax.chains.SERIALISED_KINDS, inverse_mass_matrix_spec_from
  • Optional arguments: SearchUpdater.visualize(samples=, plot_search=), perform_visualization(plot_search=), Emcee.samples_info_from(auto_correlations=), Nautilus.iterations_from(iterations_per_full_update=)

Migration

  • Before: search.make_sneakier_pool(fitness) → After: no replacement (dead path)
  • Before: af.SomeSearch(**settings_search.search_dict) for a non-Nautilus search → After: af.SomeSearch(**settings_search.search_dict_for(af.SomeSearch)) to avoid the use_jax_vmap warning
  • BlackJAXNUTS/SMC reloaded from search.json with inverse_mass_matrix="array"/"result" now raise at fit time naming the fix (pass the original seed)

Validation checklist (--auto run — plan was not pre-approved)

  • Effective level: safe (header: safe, cap: refactor → safe)
  • Plan: on the issue (refactor: search hygiene and dead code (search-extensibility A0b) #1670), written at start, unmodified since
  • Gate: tests 3073 pass / 2 skip / 3 xfail (+ nojax emulation 915 pass; downstream suites n/a, no removed symbol referenced outside PyAutoFit) · smoke afW searches/{mcmc,nest,mle} + afT searches/{Emcee,Zeus,DynestyStatic,Nautilus,LBFGS,Drawer} exit 0 · review CLEAN (Fable session over the Opus-written branch; claim "identifiers unchanged, ROUND_TRIP_XFAIL removed" basis-cited by the conformance run and the golden table test) · Heart STALE release validation incomplete: no rehearsal for current source
  • Human: plan sound in hindsight?
  • Human: diff matches plan (no scope creep)? Review items 1 and 2 above
  • Human: merge, amend, or reject — then log the outcome

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

Jammy2211 and others added 7 commits October 8, 2026 09:24
…card/thin) and dedupe log_process_state

- Delete NonLinearSearch.make_sneakier_pool and the now-orphaned SneakierPool
  with its FunctionCache helpers.
- Delete the unread NonLinearSearch.iterations attribute (the updater owns the count).
- Delete the unused discard/thin/chain computation in Zeus._fit.
- Keep one log_process_state, a module function in updater.py used by both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ns_per_full_update

- Drawer guards its timer (None under NullPaths) and builds samples from the
  search_internal argument when given, so a default-paths fit completes.
- Nautilus call_search computes the effective update interval locally and passes
  it to iterations_from instead of assigning to self.
- AbstractNest defaults number_of_cores to 1, matching every concrete search.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- NonLinearSearch logs a WARNING naming each unknown constructor kwarg captured
  in self.kwargs (never raises); save_all_samples and the search.json-recorded
  initial_values/inplace are known.
- samples_from falls back to samples.csv only on FileNotFoundError or
  NotImplementedError (no longer AttributeError), logging the fallback at WARNING.
- plot_start_point outputs only the analysis visuals (plot_search=False): the
  search has no samples yet, which the AttributeError catch used to hide (an
  empty Emcee backend).
- SettingsSearch.search_dict_for(search_cls) drops use_jax_vmap for searches
  whose __init__ does not accept it; search_dict keeps its shape.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ions once

- SearchUpdater.update passes its converted samples to visualize, which no
  longer converts them a second time for plot_results.
- Emcee.samples_via_internal_from computes the auto-correlation times once and
  shares them with the burn-in, samples_info_from and SamplesMCMC.
- Unit test: every Emcee update computes the auto-correlations exactly once.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
search.json records the inverse_mass_matrix kind string ('none' by default),
which both constructors rejected. The constructors now accept the serialised
kinds: 'none' maps back to None, and 'array'/'result' (a seed whose values were
not saved) are accepted on load and raise a clear error only at fit time.
Identifiers are unchanged; the ROUND_TRIP_XFAIL strict xfails are removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
AbstractNest described a removed auto-terminate-when-stuck feature; the base
apply_test_mode claimed the base __init__ calls it, but each search calls its own.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Move-only: the tests now sit beside the other MLE search tests, matching
autofit/non_linear/search/mle/. The empty optimize/ package is removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Oct 8, 2026
@Jammy2211
Jammy2211 merged commit 1d43b66 into main Oct 8, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/search-ext-a0b-hygiene branch October 8, 2026 09:20
samlange04 pushed a commit to samlange04/PyAutoFit that referenced this pull request Oct 16, 2026
DynestyStatic never consumed these; since A0b (PyAutoLabs#1672) they log an
unknown-keyword warning.

Refs PyAutoLabs#1693

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 16, 2026
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